We've moved discussions to Discord

Cross-Origin Resource Sharing (CORS) with multiple origins

Rafik Mrabet
For my SaaS API I need to allow multiple origins (hosts) to make requests. I'm using rack-cors gem but i'm looking for the best way to have the 'origins' value be dynamic such each new tenant account's host url needs to be added to the allowed origins.

Any ideas how to have a fresh list of origins being fetched in the cors initializer?

from my online research it sounds like making calls to the database to find out the updated list of hosts is not optimal as the DB call will be made for each API request.
another option might be to store the list in an environment variable but it needs to be dynamic instead of a static variable, so i came across a suggestion to use Redis but i'm unfamiliar with Redis

any pointers would be greatly appreciated. thanks
Notifications
You’re not receiving notifications from this thread.