Forum Discussion

samuel_meek's avatar
Frequent Visitor
4 years ago

403 Error when running 'Try It Out'

Hello! I'm new to Swagger and to APIs in general, and I am having trouble getting the Try It Out feature to work on a small sample API that I made on my local machine. Of course, I am running it on localhost:8080, which is probably the crux of the issue as per this thread from 2018:

The API runs perfectly fine, and I get responsive outputs in both Postman and Swagger Inspector, as depicted here:


However, when I go to run a 'Try It Out' test on that same customers-GET endpoint, for example, I am persistently greeted by either an HTTP 403 error or a TypeError: Failed to fetch:

The try-it test above was run in the standalone SwaggerUI at

and I put in the following CORS code, all as instructed in the resolution in the thread linked to above:

     app.use(function(req, res, next) {
         res.header("Access-Control-Allow-Origin", ""); // update to match the domain you will make the request from
         res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
What am I missing? Did I put the proper domain in the red code snippet above? Please find my API's script.js and my .yaml files attached for reference.
No RepliesBe the first to reply