Ask a Question

Swagger behind Nginx Proxy and CORS error

Newbie1
Occasional Contributor

Swagger behind Nginx Proxy and CORS error

Hi all!
I have a problem. I would like to not get an CORS error after pasting in swagger available under swagger.example.com the link to the file available under testing.example.com/plik.yaml. The vhost file: https://pastebin.com/KXTv7CBm  I am using. The commented out location block was my second attempt. After that I already started combining with different configurations from the net, but with no effect.

PS
I wonder if it is possible to make proxy + cors configured on swagger.example.com in such a way, that I do not have to add:
add_header Access-Control-Allow-Origin "https://swagger.example.com";
on every server which will use swagger available under swagger.example.com. Do any of you guys have any ideas?
11 REPLIES 11
Newbie1
Occasional Contributor

Thank you @ponelat . 🙂 I am going to ask backend devs what does mean this error. I hope I reached the end. I will let you know.

 

PS

Is it possible to do some kind of reset origin header? On one testing server I have an error from cors 

 

has been blocked by CORS policy: The 'Access-Control-Allow-Origin' header contains multiple values 'https://swagger.example.com, https://swagger.example.com', but only one is allowed.

 

 but in config I have currently only one occurence of this header. Is it possible that origin header is remembered due to this:

 

add_header 'Access-Control-Max-Age' 17286000;

 

 

Newbie1
Occasional Contributor

@ponelat I think it works. I have the same response when execute curl command from shell. Could you tell me is there any possibility to configure docs.swagger.example.com some way to not provide any configuration on any servers like t1.example.com, t2.example.com and so on.

cancel
Showing results for 
Search instead for 
Did you mean: