CORS Error
Anonymous
HOBBYOP

a month ago

I am getting CORS (Cross-Origin Resource Sharing) error. I checked to add CORS headers in bucket settings, but I couldn't add. Could you help?

I am sharing the error details here:

XMLHttpRequest at ... from origin .... has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.Understand this error admin.js:1551 PUT ...

Solved$10 Bounty

1 Replies

Status changed to Open Railway 28 days ago


domehane
FREE

a month ago

Hello,

so railway doesn't have a cors settings panel in the dashboard you have to configure it via the aws cli. run this command with your credentials:

AWS_ACCESS_KEY_ID=your_access_key_id \

AWS_SECRET_ACCESS_KEY=your_secret_access_key \

aws s3api put-bucket-cors \

--bucket your_bucket_name \

--endpoint-url https://storage.railway.app \

--cors-configuration '{

"CORSRules": [

{

"AllowedHeaders": ["*"],

"AllowedMethods": ["PUT","POST"],

"AllowedOrigins": ["https://your%5Fdomain.tld"],

"MaxAgeSeconds": 3000

}

]

}'

just replace your_access_key_id, your_secret_access_key, your_bucket_name and your_domain.tld with your actual values ; your credentials are in the credentials tab of your bucket on the railway canvas

source: docs.railway.com/storage-buckets/uploading-serving

Hope this help you :)


Status changed to Awaiting User Response Railway 28 days ago


Railway
BOT

21 days ago

This thread has been marked as solved automatically due to a lack of recent activity. Please re-open this thread or create a new one if you require further assistance. Thank you!

Status changed to Solved Railway 21 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...