Skip to content

Swagger UI API testing- 'Invalid CORS Request' response for all requests methods expect for 'GET' requests #488

@devcode100

Description

@devcode100

Overview of the issue:

version: 6.3.0

I have set up the Jhipster registry project for Swagger API documentation.Its now the central place for gateway and all other microservices API.
When testing API's for gateway and other microservices, if the request verb is other than 'GET',ie. if the request method is POST, PUT, DELETE- 'Invalid CORS request' is thrown.
Response status: 403, Invalid CORS request
All API requests with GET verb works fine.

Context path is configured as below:
jhipster registry: /registry
gateway: /gateway

In local(profile local) set up everything is working fine from Swagger UI, but once its deployed to respective environments requests starts failing.

PF the below swagger generated URL for API testing:
gateway authentication API:
https://xx.99.xx.64/registry/services/gateway/gateway:78b627b6a671cd1a33e53ae603e0eb12/gateway/api/authenticate
microservice: micro1
https://xx.99.xx.64/registry/services/micro1/micro1:a8ebfb8ee491ceceda595c63e3e87966/api/save

This APIs fails from swagger,but works fine when tested through Postman

CORS configuration for registry,gateway

jhipster:
  # CORS is only enabled by default with the "dev" profile, so BrowserSync can access the API
  cors:
    allowed-origins: '*'
    allowed-methods: '*'
    allowed-headers: '*'
    exposed-headers: 'Authorization,Link,X-Total-Count'
    allow-credentials: true
    max-age: 1800
  security:
    client-authorization:
      client-id: internal
      client-secret: internal
    authentication:
      jwt:
        base64-secret: _xxsecretkeyxx_

Authentication: JWT

Couldn't figure out the issue as the set up works fine in local and the swagger generated API URLs responds successfully when tested from postman

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions