CORS backend error
Hi! I have my backend hosted on railway but my frontend on Azure. I have a lot of endpoints on my API, but I'm getting CORS error on websocket. Whenever I try to stablish a connection it gives me this error:
Access to XMLHttpRequest at 'https://dev-api-agendai.up.railway.app/issues' from origin 'https://agendai-dev.azurewebsites.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource.
Solution:Jump to solution
Hi! I have my backend hosted on railway but my frontend on Azure. I have a lot of endpoints on my API, but I'm getting CORS error on websocket. Whenever I try to stablish a connection it gives me this error:
Access to XMLHttpRequest at 'https://dev-api-agendai.up.railway.app/issues' from origin 'https://agendai-dev.azurewebsites.net' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource....
65 Replies
Project ID:
cc386d0c-2f7d-465e-97db-3e498cbd5176
cc386d0c-2f7d-465e-97db-3e498cbd5176
HI there Brody! As you can imagine, I already have everything setup in terms of code.
I'm looking foward to see if there is any block in railway servers about WEBSOCKET and CORS policy?
railway has full support for websockets, and will not remove any headers
Can you guide me on how to see these details?
network tab in devtools
Thanks Brody, I'll look into it.
<wss://dev-api-agendai.up.railway.app/issues> is not a websocket endpoint though?
Indeed, this is not the websocket endpoint but it's the one that the console is showing.
wss://dev-api-agendai.up.railway.app/socket.io/?EIO=4&transport=websocket
looks good, is there a pending network request?
Not that I had notice.
In localhost, isn't everything all right with my headers?
why do you keep showing me the /issues endpoint, it has nothing to do with websockets
I'm sorry, let me show you the error in the console because I'm not sure if the error is with websocket in API or CORS policy.
i do not get these errors when i visit https://agendai-dev.azurewebsites.net/
i see a successful websoscket connection open, and it stays open without issue
What about this error 503?
The 3rd error here on the console, failed 503.
i dont see 503 on my end
Could I guide you to the page where the error happens?
yes please
Please, login here: https://agendai-dev.azurewebsites.net/login
user: admin1
pass: @admin10
When you log in, you can select the blue button and also one of the gray bellow it.
Like that.
hmmm where did u get this error?
loging in
Can u try again, please?
works
Okay, u need to get to this page:
After these steps
clicking the blue arrow doesnt do anything
some loading dots pop up, disapear and nothing happens
Try choosing other GUICHÊS please.
Like the third ou fourth.
okay im here
See your name?
i did, but it disapeared before my eyes
Really? So it's empty?
Wait a sec
Just a sec I'll create a new one
im getting a bunch of 503 status codes too
Try refreshing this page
it should appear another one with your name, and then you can click on ATENDER right in side of it
okay refreshed and no errors so far
Are you here?
no errors
Okay, the error will appear when you click on this stream logo.
On the button actually.
That has the text EXIBIR NA TV.
no errors
wait
whaat
it worked with you
why? lol
nvm webscoket conn dropped and wont reconnect
https://agendai-dev.azurewebsites.net/tv it should appear here...
and it worked for a moment but now I get a bunch of erros too
your app is just very unstable lol, not a railway issue
xD
Do u have any clue where this error is coming from?
your unstable code
Okay Brody, thanks for you help I'll look further into it.
Thank you a lot.
haha no problem
After all, the server crashed:
🥲
youll have that
you can always look at the logs
Looking into it to see any problems.
But I think this prisma error is a generic one or it was given due to connection lost in the app.
just looks like a code issue on your part