krakenjs / swaggerize-express

Design-driven apis with swagger 2.0 and express.
Other
355 stars 81 forks source link

CORS support #72

Closed techdubb closed 9 years ago

techdubb commented 9 years ago

Is there a known way to implement CORS, especially preflight, with swaggerize-express?

Thanks!

tlivings commented 9 years ago

Should be able to do app.use(cors) before adding swaggerize-express. Does this not work?

techdubb commented 9 years ago

The before adding swaggerize-express part was the bit I messed up. Working now.

Thanks for the quick reply!

tlivings commented 9 years ago

No problem. Perhaps I should just embed cors support directly.

aredridel commented 9 years ago

Just say no to feature creep!

tlivings commented 9 years ago

:) the only reason I mention it is due to how common this need is for reading Api definitions from a swagger ui.

aredridel commented 9 years ago

True. Way to make a spec that incorporates ALL the cross-cutting concerns.

techdubb commented 9 years ago

I'm not sure embedding cors directly would be needed.

Admittedly, this was a lack of experience with express middleware and the importance of .use order.

In retrospect, using cors prior to wsaggerize-express makes sense, but since the "magic" of .use is so well abstracted, the order of things isn't immediately obvious.