Allow access api form localhost

[root@bw-ss2 blog-and-tools]# curl -vv http://127.0.0.1:2368/ghost/api/v2/content/settings/?key=xxxxxxxxxaaaaa

  • About to connect() to 127.0.0.1 port 2368 (#0)
  • Trying 127.0.0.1…
  • Connected to 127.0.0.1 (127.0.0.1) port 2368 (#0)

GET /ghost/api/v2/content/settings/?key=assxxxxxxxxxxxxxxxxa HTTP/1.1
User-Agent: curl/7.29.0
Host: 127.0.0.1:2368
Accept: /

< HTTP/1.1 301 Moved Permanently
< X-Powered-By: Express
< Cache-Control: public, max-age=31536000
< Access-Control-Allow-Origin: *
< Location: httwww.myfreax.com/ghost/api/v2/content/settings/?key=asdddwwww
< Vary: Accept, Accept-Encoding
< Content-Type: text/plain; charset=utf-8
< Content-Length: 119
< Date: Fri, 21 Jun 2019 10:57:48 GMT
< Connection: keep-alive
<

  • Connection #0 to host 127.0.0.1 left intact
  • What version of Ghost are you using?
    2.2.5

@huangyanxiong01 do you have your url configured as “https”? If so, your request to localhost when using “http://localhost:2368” will be automatically redirected to the configured https url.

Quick-fix is to change your configured url to http://localhost:2368 if this is a local development install. If you want to keep the configured url you will need to send requests to https://localhost:2368 or add the X-Forwarded-Proto header as in curl -H 'X-Forwarded-Proto: https' http://localhost:2368/...

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.