0

I'm getting a error Access-Control-Allow-Origin when attempting to use Vue.js and axios to get data from the WordPress APIs.

I'm using OpenLiteSpeed on digital ocean to host a headless WordPress APIs. Today I had to restart the server to update my security certificate. After restart, I started getting an error with my axios get request, but only when I use the base URL, not www.

For example, if you go to www.samiamido.com everything works fine. But if you go to just samiamido.com there is a CORS related error. I don't think that this happened before I updated the cert this morning.

I created a simple test site on my local machine and got the same error.

I don't remember ever setting www.samiamido.com as a response header, or even where I would have done that at (openlitespeed console, wp-admin, or whatever).

Anyone now where to even start to debug? Getting very frustrated at this point!

Vy Do
  • 46,709
  • 59
  • 215
  • 313
  • Possible duplicate of [Why does my JavaScript get a "No 'Access-Control-Allow-Origin' header is present on the requested resource" error when Postman does not?](https://stackoverflow.com/questions/20035101/why-does-my-javascript-get-a-no-access-control-allow-origin-header-is-present) – Pavlo Zhukov May 01 '19 at 00:00
  • To resolve this problem you may use this plugin https://chrome.google.com/webstore/detail/allow-control-allow-origi/nlfbmbojpeacfghkpbjhddihlkkiljbi?hl=en in pair with https://chrome.google.com/webstore/detail/set-character-encoding/bpojelgakakmcfmjfilgdlmhefphglae?hl=en – Pavlo Zhukov May 01 '19 at 00:04
  • You can setup CORS from openlitespeed settings by following https://openlitespeed.org/kb/setting-up-cors-on-openlitespeed/ – Eric Jul 09 '19 at 16:22

0 Answers0