ALLOWED_DOMAIN env variable configuration issue on Railway backend
chris-opendata
HOBBYOP

a month ago

I lately changed ALLOWED_DOMAIN env variable from (an example)

https://mydomainname.com,https://www.mydomainname.com

to

https://mydomainname.com,https://www.mydomainname.com,https://api.mydomainname.com

And saved by clicking the tick icon.

I also added https://api.mydomainname.com , along with the https://mydomainname.com,https://www.mydomainname.com two in the frontend middleware allowed origin list.

I then git push and redeployed the backend service online.

All good so far.

But, when I launched my site, I noticed the following error in the browser's console:

Access to XMLHttpRequest at 'https://api.mydomainname.com/api/admin/system-setting' from origin 'https://mydomainname.com' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.

I went to Railway backend variable setting, clicked copy icon button, I get https://mydomainname.com,https://www.mydomainname.com.

But, if I clicked the edit button, it shows me https://mydomainname.com,https://www.mydomainname.com,https://api.mydomainname.com.

Although the configured allowed origin string inconsistency between copy and edit may or may not be the direct cause, it nonetheless is a problem.

Did I miss some steps, or is it because of a Railway bug?

Look forward to any suggestion.

Thanks

Solved

2 Replies

brody
EMPLOYEE

a month ago

Hello,

You have not yet applied the changes.


Status changed to Awaiting User Response Railway about 1 month ago


brody

Hello,You have not yet applied the changes.

chris-opendata
HOBBYOP

a month ago

Thank you for your speedy reply. However, I am a bit confused. When I git push the changes, I saw the backend started rebuilt and redeployed the codebase successfully with green ticks and Active status on the right-hand side panel. So, I assumed that all were done automatically. That would be my expectation as well. Why do I need to go an extra step to do the manual click on Deploy? Did I miss something here? Thanks.

P.S. Did a bit experiment. Any changes to env vars need to click project-level Deploy button, regardless service level redeployment. I don't know the reason, but I suggest:

After any environment var changes, the related service redeloyment due to Git Push should take effect the env var too. It is logical, isn't it.


Status changed to Awaiting Railway Response Railway about 1 month ago


Status changed to Solved brody about 1 month ago


Loading...