[Vuejs]-How to get data use fetch API correctly in vue js?

2👍

Your backend application runs on a different domain than your client application?
That causes the CORS header ‘Access-Control-Allow-Origin’ missing error because basically your client-side is not authorized to access your backend using its domain.
Add cors headers in your first middleware in the backend.
you can set a header of

Access-Control-Allow-Origin: '*'

to allow any origin to access the backend.

Or setting your specific domain to allow only it to access your backend.

Access-Control-Allow-Origin: 'https://example.com'

Where https://example.com is the domain of your client side application.

Leave a comment