Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support cors #449

Closed
daddykotex opened this issue Sep 9, 2022 · 6 comments
Closed

Support cors #449

daddykotex opened this issue Sep 9, 2022 · 6 comments

Comments

@daddykotex
Copy link
Contributor

Some users have requested the ability to generate the code to support CORS. This trait currently is not taken in consideration by the simpleRestJson protocol.

https://awslabs.github.io/smithy/2.0/spec/http-bindings.html?highlight=cords#cors-trait

@kubukoz
Copy link
Member

kubukoz commented Sep 10, 2022

One thing that bothers me about the trait is that there's just one origin. A string, not a list. It feels very limiting to only support one origin, as normally you might want to include e.g. your development setup (localhost).

Additionally, it requires hardcoding the full domain name (& port as well as protocol, which are also part of the origin) - in my view that's not going to go well together with things like deploying to multiple environments (even just test/prod).

We should probably raise this in the upstream.

@kubukoz
Copy link
Member

kubukoz commented Sep 10, 2022

For example, http4s supports a list of allowed origins:

image

so that when you make a request from one of them, it'll be returned in the allowed origin header. I believe that's a pretty common pattern even outside of http4s.

@Baccata
Copy link
Contributor

Baccata commented Sep 10, 2022

Some users have requested the ability to generate the code to support CORS. This trait currently is not taken in consideration by the simpleRestJson protocol.

This is one of the things I'm really not willing to provide OOTB support for, because it can be supported by http4s-level middleware easily in third-party code/userland. See the http4s docs.

Moreover, as @kubukoz states, the cors trait ain't as flexible as it should, so providing OOTB support would be lacking.

What we can do however is document how to retrieve hints from services (both in a polymorphic and monomorphic manner), and document an example of doing that for wiring a CORS middleware.

@Baccata
Copy link
Contributor

Baccata commented Sep 10, 2022

Issue opened upstream : smithy-lang/smithy#1396

@daddykotex
Copy link
Contributor Author

Opened #456 to document how to implement such a thing on your own until the issue is fixed upstream

@Baccata
Copy link
Contributor

Baccata commented Oct 27, 2022

Gonna close this, the documentation on how to enable CORS is enough.

@Baccata Baccata closed this as completed Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants