достучаться до VPS.
Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
Вот такой конфиг
location ~ ^/api/(.*)/?$ {
add_header 'Access-Control-Allow-Origin' $http_origin;
expires off;
if ($request_method = 'OPTIONS') {
# Tell client that this pre-flight info is valid for 20 days
add_header 'Access-Control-Max-Age' 1728000;
add_header 'Content-Type' 'text/plain charset=UTF-8';
add_header 'Content-Length' 0;
return 204;
}
add_header 'Access-Control-Allow-Methods' $access_control_allow_methods always;
add_header 'Access-Control-Allow-Headers' $access_control_allow_headers always;
add_header 'Access-Control-Allow-Credentials' 'true' always;
# required to be able to read Authorization header in frontend
add_header 'Access-Control-Expose-Headers' $access_control_expose_headers always;
proxy_pass http://vuejobs_api$request_uri;
}
При этом Advanced REST Client нормально общается.
Ошмбка в браузере, при использовании axios.
https://www.npmjs.com/package/cors
Обсуждают сегодня