How to get Caddy, React, and Express to play nice with each other?
So essentially I have a bare minimal application that uses Caddy for reverse proxying, React JS as a frontend, and a Node / Express backend that I would like to deploy to Railway. I am using Dockerfiles for each service as this is a requirement for a future project.
The current issue I am running into is probably a noob-level question but I am getting a:
CORS header ‘Access-Control-Allow-Origin’ missing
error. I did make sure to add cors in the server.js
file:
Also, an aside, I made sure to run this code as per the common errors documentation page for Railway:
Here is the project link:
inviteRailway
Railway
Railway is an infrastructure platform where you can provision infrastructure, develop with that infrastructure locally, and then deploy to the cloud.
6 Replies
Project ID:
bd9d2446-119b-4082-a16d-a0e471fa974d
bd9d2446-119b-4082-a16d-a0e471fa974d
Navigating to the Frontend:
https://railway-deployment-testing.up.railway.app/test
After navigating to the Frontend, there is a button which requests some API. Here is a simple
GET
endpoint in the Express backend:
/api/v1/helloWorld
That endpoint will throw the CORS error from the React application.
Currently, the backend service is unexposed publicly and I intend to only use internal networking. However, I did test that the backend service works when it has its own exposed domain.Railway Deployment Testing
Web site created using create-react-app
Solution
The private network is IPv6 only so your application needs to bind to
::
@Brody You're amazing! Thanks that was all it was.
no problem!