Im trying to consume posts with the public api.
React App + Axios <-> Ghost
But why im getting:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at <_BIG_URL_CHUNK_>.
The url from which im trying to consume is:
something.url.com
and my ghost blog lives on:
www.url.com
mskian
April 26, 2018, 4:37am
2
Add CORS Origin in the Nginx Header
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Origin' 'https://example.com';
Save the File & restart Nginx
sudo service nginx restart
1 Like
David
April 26, 2018, 5:40pm
3
You should not need to make any changes to your nginx file for this to work.
There is a guide to using the public API I think you will find useful.
@David
The solution that is described on Ghost doesnt work outside a dev enviroment.
Have you tried it ?.
David
April 27, 2018, 2:58pm
5
@cristiandley
We use this method actively on blog.ghost.org so it certainly works
Have you added your domain to the trusted domains table?
If you can provide some more details on what you have tried so far then we can investigate this further
@David
I added the domain to the trusted table. It is the same domain, except it is located on a sub-domain.
ghost.yyy.com
something.yyy.com
David
April 27, 2018, 3:04pm
7
Okay, the domains are quite explicit so it needs to include the subdomain.
Wildcards are also not allowed
The domain also has to include the protocol.
1 Like
No idea what is the problem.
My ghost.yyy.com lives in server A
And something.yyy.com lives in server B
adding those values as in the guide does not work at all.
It would be much easier to help you if you provided the real URLs you’re trying to use. As David mentioned, you need to include the protocol.
So for example, in the trusted domains table for blog.ghost.org , we have https://ghost.org
and then we are able to fetch posts to display on our main site.
@Hannah Okey, this is it
tried adding subdomain and with no subdomain
Hannah
May 10, 2018, 5:08pm
11
Ok, and what is the exact domain that are you making the API request from?
system
Closed
May 24, 2018, 5:08pm
12
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.