wordpress-clients / hybrid

[I don't have time to work on this anymore. Use at your own risk] Build WordPress based PWA, iOS, Android & Windows phones apps in minutes!
MIT License
1.02k stars 348 forks source link

[Question] Headers settings for wp api #366

Closed mattbag closed 7 years ago

mattbag commented 7 years ago

Hi, apparently I have a cors issue, and I can't find where to place my headers settings.

In config.cson I tried: "headers": "Accept": "application/jpg" "Access-Control-Allow-Origin" : "*" and with anonymous instead of wildcard

Also through the whitelist plugin in config.xml <access origin="http://the-site.com.au" /> <allow-navigation href="http://the-site.com.au/*" />

The error: XMLHttpRequest cannot load http://the-site.com.au/wp-json/wp/v2/posts?_embed=true&order=desc&orderby=date&page=1&per_page=5&status=publish. Redirect from 'http://the-site.com.au/wp-json/wp/v2/posts?_embed=true&order=desc&orderby=date&page=1&per_page=5&status=publish' to 'http://the-site.com/wp-json/wp/v2/posts?_embed=true&order=desc&orderby=date&page=1&per_page=5&status=publish' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.

I've never had to edit headers in my api source with other tests, but is it what I need to do now in my wp instance? Thanks a lot for this, and for the great project!

shprink commented 7 years ago

Can you share the apiUrl of your WP please? I can check from here

mattbag commented 7 years ago

@shprink the-beautyinsider.com.au/wp-json I get 200 with every external test, and can read data using your angular 2 service too

Thanks

shprink commented 7 years ago

I can reproduce. What version of WP/WP-API(if installed) do you use?

mattbag commented 7 years ago

Hey, I have 4.7. At the moment it's working with my staging version, so it will be good enough for testing. I will close this since the settings I mentioned at the top should be working for me.

Thanks again for all your amazing works!