I've configured Swagger for my Web API 2.2 app and it loads locally but I get a CORS error when I try to access it on a remote server. Also, just to get to the swagger page I have to be very explicit with the url. For example:
https://example.com/swagger/ui/index
As opposed to:
example.com/swagger/
I think I encountered a somewhat similar issue on a previous project where I had to provide the full explicit url as displayed in my first example, but on this previous project, using the long form url displayed the working swagger page as expected. Is this due to https configuration? Is there a special swagger setting that can be configured to allow the short url in an https environment? On remote servers the following error message displays which appears to clearly indicate a CORS error:
"Can't read from server. It may not have the appropriate access-control-origin settings."
I've tried everything in the following thread but I'm still having the issue:
CORS support for PUT and DELETE with ASP.NET Web API
If I submit an API search request to the remote server then a response header of "Access-Control-Allow-Origin > *" is returned so it appears that CORS is enabled for the remote server. Not sure why swagger is encountering what appears to be a CORS error?