5 months ago
ProjectID: ab5bb9c9-5cc0-4ab6-84bc-63e789bb585c
I am new to Railway and I am trying to build a full stack web app. I have my PostgreSQL DB and my Spring Boot backend deployed in Railway and working correctly. I can access my API endpoints from Postman using the public URL of the Spring Boot app. However when trying to make a call to the same endpoints from the NextJS app I am getting 403 Forbidden. I can't seem to access any logs that give me more info than that.
0 Replies
update: changed the allowed origins to the public URL of the frontend and it works. I wonder if there's a better way to do this using the internal railway network maybe?
5 months ago
Hi, I have several Spring Boot applications deployed on Railway without any problem, but you have to consider an optimal configuration of the CORS in order to be able to make the communication in an optimal way between the frontend and the backend.
5 months ago
there is! instead of using your backend’s public url while hosted, use its private url. Make sure to use the environment variable rather than hardcoding and set the public URL as the default if the environment variable isn’t available so you can continue developing locally!
For using the private url, how would I configure this with the port and everything? I'm having a bit of a hard time getting them to work
Do you have a brief example of how you got your CORS configuration to work for such cases?
5 months ago
take a look at the docs here https://docs.railway.com/reference/private-networking
Ah, I tried but it didn't help me that much. Examples help me best but I will keep looking <:salute_guy:1244814929630855188>
5 months ago
This may help you https://www.baeldung.com/spring-cors
5 months ago
!s
Status changed to Solved adam • 5 months ago