N
N
nuclear_kote2017-06-13 01:35:03
Nginx
nuclear_kote, 2017-06-13 01:35:03

How to create an error page with CORS headers in nginx?

Tried like this:

server {
    listen 80;
    server_name test.example.com;
    location / {
        proxy_pass http://10.172.10.42:3443;
        error_page 413 =413 /413;
    }

    location /413 {
    	proxy_set_header X-Target $request_uri;
    	proxy_set_header Access-Control-Allow-Origin "*";
     	proxy_set_header Access-Control-Allow-Credentials "true";
    	proxy_set_header Access-Control-Allow-Methods "OPTIONS, GET, POST, DELETE, PUT";
    	proxy_set_header Access-Control-Allow-Headers "Content-Type, Access-Control-Allow-Origin, Access-Control-Allow-Credentials, Access-Control-Allow-Methods, Access-Control-Allow-Headers, Authorization, X-Requested-With";
    }
   
 proxy_read_timeout 950s;
}

does not work

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexey Ukolov, 2017-06-13
@nuclear_kote

add_header Access-Control-Allow-Origin "*" always;
nginx.org/ru/docs/http/ngx_http_headers_module.htm...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question