Giter Site home page Giter Site logo

Question about CORS about swagger-node HOT 3 CLOSED

swagger-api avatar swagger-api commented on April 30, 2024
Question about CORS

from swagger-node.

Comments (3)

fehguy avatar fehguy commented on April 30, 2024

Hi, take a look here:

https://github.com/wordnik/swagger-core/wiki/CORS

for point 2, you simply need to add the headers when writing the response back to the client. If you're using the swagger-node-express module, it'll add them automatically:

https://github.com/wordnik/swagger-node-express/blob/master/Common/node/swagger.js#L74

from swagger-node.

JamieMoon avatar JamieMoon commented on April 30, 2024

Hi, Fehguy

Thank you for such a quick response.

What I had done before were

  1. launch swagger-node-express example
    D:\Lab\Node.js\kws\swagger-node-express> node Apps\mystore\main.js

  2. Check header

  • D:\Lab\Node.js\kws\swagger-node-express>curl -I http://localhost:8001/docs
    HTTP/1.1 302 Moved Temporarily
    X-Powered-By: Express
    Location: /docs/
    Date: Thu, 16 Jan 2014 02:16:57 GMT
    Connection: keep-alive
  • D:\Lab\Node.js\kws\swagger-node-express>curl -I http://localhost:8001/api-docs
    HTTP/1.1 200 OK
    X-Powered-By: Express
    Access-Control-Allow-Origin: *
    Access-Control-Allow-Methods: GET, POST, PUT, PATCH, DELETE
    Access-Control-Allow-Headers: Content-Type, api_key
    Content-Type: application/json; charset=utf-8
    Date: Thu, 16 Jan 2014 02:17:04 GMT
    Connection: keep-alive
  1. Tested my API list (Not Node.js or Swagger-Integrated) in the input box of swagger API explorer
    these API list is located in remote server and have no CORS header in their response

In '3)', as i explained what i have done before, wiki/CORS and you're telling me that
i have to add the CORS header in their(remote server APIs) response header, right?

Thank you for your patience.

from swagger-node.

fehguy avatar fehguy commented on April 30, 2024

That is correct. The CORS support has to be on the remote server, not the server providing the swagger-ui.

from swagger-node.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.