Skip to content
Advertisement

Strapi v4 throwing cors exception

Im new to strapi and I have downloaded strapi v4 and as front-end I use vue.js.

Now I created categories and I am trying to fetch those with my vue app but I’m getting a cors error.

JavaScript

In the documentation I see I can override the origin on the cors middleware, but I don’t know how.

I’ve tried it with resolve and then set the config, but that breaks the cms.

JavaScript

Advertisement

Answer

After spending a few hours on the internet I finally got it working.

In my config/middlewares.js I had to replace strapi::cors to this:

JavaScript

Don’t forget to add port number, because it will not work if you don’t.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement