R
R
Rustam Akimov2019-06-01 19:21:48
Nginx
Rustam Akimov, 2019-06-01 19:21:48

How to set up CORS?

I use the Nginx + PHP-FPM bundle for requests to set such headers

add_header 'Access-Control-Allow-Origin' 'http://localhost:8080';
        add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS, PUT';
        add_header 'Access-Control-Allow-Headers' '*';
        add_header 'Access-Control-Expose-Headers' '*';

When I send a request from my vue application via axios I get an error
Access to XMLHttpRequest at ' localhost/api/institutes/6fe90daaeeaa3f272d8196bb7... ' from origin ' localhost:8080 ' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'. The credentials mode of requests initiated by the XMLHttpRequest is controlled by the withCredentials attribute.

But in response the answer I expected comes
How to fix this error?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
K
ky0, 2019-06-01
@ky0

Doesn't it bother you that there is nothing about port 8080 in the request url? Well, in general, why is he in principle?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question