Giter VIP home page Giter VIP logo

Comments (8)

theganyo avatar theganyo commented on June 30, 2024

Well, there are a couple of options to dealing with cors:

  1. Just install and use a middleware like cors. It's generic, but it works in most cases. This is actually part of the default pipeline in the new swagger-node-runner. If you do this, you don't need to include anything specific in your swagger, but it also won't show up in your documentation - if that's something you want.
  2. Manually add the options operation to each of your Swagger paths with an appropriate controller that returns the necessary information for options.

from swagger-express.

rustychapin avatar rustychapin commented on June 30, 2024

Thank you! I will implement cors and give it a go. You mentioned that it
is the new swagger-node-runner module. Is that currently released?
On Dec 3, 2015 9:46 AM, "Scott Ganyo" [email protected] wrote:

Well, there are a couple of options to dealing with cors:

Just install and use a middleware like cors
https://www.npmjs.com/package/cors. It's generic, but it works in
most cases. This is actually part of the default pipeline in the new
swagger-node-runner. If you do this, you don't need to include anything
specific in your swagger, but it also won't show up in your documentation -
if that's something you want.
2.

Manually add the options operation to each of your Swagger paths with
an appropriate controller that returns the necessary information for
options.


Reply to this email directly or view it on GitHub
#3 (comment)
.

from swagger-express.

theganyo avatar theganyo commented on June 30, 2024

If you're using [email protected], you're already using the latest. If not, you'll need to do a little upgrade work... But it's pretty easy, start here: https://github.com/theganyo/swagger-node-runner/releases/tag/v0.6.0.

from swagger-express.

rustychapin avatar rustychapin commented on June 30, 2024

I am indeed running 0.6.0. Do I need to install cors or just implement it
according to the cors npm documentation?
On Dec 3, 2015 10:30 AM, "Scott Ganyo" [email protected] wrote:

If you're using [email protected], you're already using the
latest. If not, you'll need to do a little upgrade work... But it's pretty
easy, start here:
https://github.com/theganyo/swagger-node-runner/releases/tag/v0.6.0.


Reply to this email directly or view it on GitHub
#3 (comment)
.

from swagger-express.

theganyo avatar theganyo commented on June 30, 2024

Actually, if you're running the latest, you don't even need to do that. You just need to make sure the existing fitting is listed for your pipe. The swagger_controllers pipe should look something like this and have "cors" listed as the first item after the error handler...

    swagger_controllers:
      - onError: json_error_handler
      - cors
      - swagger_params_parser
      - _swagger_security
      - _swagger_validate
      - express_compatibility
      - _router

If you have that, it should automatically route all request through the cors for any of your declared paths.

If you have that and it's not working, we'll need to dig deeper to figure out what's happening for you...

from swagger-express.

rustychapin avatar rustychapin commented on June 30, 2024

Bummer... I do indeed have that. I detailed my setup and the problem at stack overflow:
http://stackoverflow.com/questions/34016007/swagger-ajax-preflight-options

It seemed odd to me that it wasn't working. Take a look and see if anything comes up.

from swagger-express.

rustychapin avatar rustychapin commented on June 30, 2024

Scott,

Have you had a chance to look at the comments I posted including the stack
overflow posst?

http://stackoverflow.com/questions/34016007/swagger-ajax-preflight-options

Thanks again!

Rusty

On Thu, Dec 3, 2015 at 10:51 AM, Scott Ganyo [email protected]
wrote:

Actually, if you're running the latest, you don't even need to do that.
You just need to make sure the existing fitting is listed for your pipe.
The swagger_controllers pipe should look something like this and have
"cors" listed as the first item after the error handler...

swagger_controllers:
  - onError: json_error_handler
  - cors
  - swagger_params_parser
  - _swagger_security
  - _swagger_validate
  - express_compatibility
  - _router

If you have that, it should automatically route all request through the
cors for any of your declared paths.

If you have that and it's not working, we'll need to dig deeper to figure
out what's happening for you...


Reply to this email directly or view it on GitHub
#3 (comment)
.

from swagger-express.

theganyo avatar theganyo commented on June 30, 2024

Hey Rusty,

Sorry I haven't gotten back to this before now. Do you happen to have a project you can share that recreates the issue? I've attempted to recreate myself, but I can't seem to hit whatever it is that you're hitting.

from swagger-express.

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.