Where do I set Access-Control-Allow-Origin:*?

Asked 1 years ago, Updated 1 years ago, 118 views

I'm developing with Ravel and Vue, but I'm having trouble with this kind of error.
Where can I set Access-Control-Allow-Origin:* to resolve this?

blocked by CORS policy

laravel vue.js cors

2022-09-30 20:17

1 Answers

I set it to the .htaccess file.
Add the following code to .htaccess.

<IfModule mod_headers.c>
   Header add Access-Control-Allow-Origin "*"
   Header add Access-Control-Allow-Headers"*"
   Header add Access-Control-Allow-Methods "OPTIONS, GET, POST, PUT, DELETE"
   Header add Access-Control-Max-Age 86400
</IfModule>

This file is located in the public folder.If it does not exist, refer to the image below. Rename .htaccess.example to .htaccess.

Enter a description of the image here


2022-09-30 20:17

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.