1cookie
4 years agoOccasional Contributor
Change domain for 'try it out' feature
Hi,
So currently I'm using the standalone version of swaggerUIBundle:
window.onload = function () {
// Begin Swagger UI call region
const ui = SwaggerUIBundle({})
}
On the front-end. When I enter the "try it out" feature and press the execute button; the request URL and the cURL string are both using the same domain which my page is on. My API sits on another domain however and so the response returns a page not found (as you would expect). Is there a config setting allowing me to serve my APIs from another domain?
Thanks
Thanks
You need to enable CORS on your API server, localhost:8007. The way you do this depends on the server and framework used, check out https://enable-cors.org/server.html
Alternatively, hosting Swagger UI on the same server:port as the API server will avoid CORS altogether.