CORS origin from environment variables? #1605
-
It seems that you can read the origin of the request and base the allowed CORS origin from it based on the docs:
But this is not what I want. I want to restrict the CORS origin depending on the environment url (DEV, QA, UAT, PROD). Is there a way to get context.env.SOME_URL and use that as CORS origin? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 2 replies
-
Try it like this: https://hono.dev/getting-started/cloudflare-workers#using-variables-in-middleware |
Beta Was this translation helpful? Give feedback.
-
Thank you for the quick reply. This is works great! |
Beta Was this translation helpful? Give feedback.
-
@franklloydteh @yusukebe are you able to share how you got this working with the cors middleware? I can't seem to adapt the linked example for basicAuth in a way that works. Thanks in advance for any additional guidance you can share. |
Beta Was this translation helpful? Give feedback.
@franklloydteh
Try it like this:
https://hono.dev/getting-started/cloudflare-workers#using-variables-in-middleware