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
Solved! Go to Solution.
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.
You need to specify the target server in your API definition, for example:
openapi: 3.0.0
servers:
- url: 'https://example.com/api'
or
swagger: '2.0'
host: example.com
basePath: /api
schemes:
- https
hi,
Thanks for that. Using your first option - the URLs are now pointing at my API on the correct domain. I still have an issue where the server fails to load the response:-
I've checked the above in my local browser and the payload returns successfully.
Thanks
What's the error message in the Console tab of the browser developer tools?
Ah, yes - It's a CORS issue:-
How do we get over this hurdle? Am I able to configure Docker to get around this?
Thanks for all your help and a great piece of software.
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.
Thanks Helen