Problem/Explanation
I am currently building a webapp on DigitalOcean where I have the front/backend separated into their respective docker containers as such:
- Frontend: ReactJS, mapping 80:3000 (going to 80 on server from container’s port of 3000)
- Backend: ExpressJS/NodeJS mapping 3001:3001 (mapping 3001 on server from container port of 3001)
I am currently only using HTTP, and everything so far is working as intended, the frontend successfully calls to the backend.
However, whenever I turn on Cloudflare (even when I completely turn off SSL features so its still HTTP) my backend suddenly doesn’t receive any requests from the frontend, and even doing curl mywebsite.com:3001/exampleapiRoute
doesnt yield anything, but I know that my backend is still working, as doing curl localhost:3001/exampleapiRoute
does return something(and did work previously when Cloudflare was off).
Why is Cloudflare breaking my application? I haven’t seen any errors,warnings,etc that indicate that something is going wrong.
Code snippets
My frontend calls like this:const url = 'http://mywebsite.com:3001/exampleapiRoute';
await Axios.post(url, {
eventId: params.eventId,
userToken: props.user.token
}).then((response) => {
etc
and my backend follows this:
const express = require("express");
const webserver = express();
const cors = require("cors");
const mysql = require("mysql");
const PORT = 3001;
// db connection here
webserver.use(cors());
webserver.use(express.json());
webserver.post("/exampleapiRoute", (req,res) => {
res.send({
response:"Hello world"
)}
});
webserver.listen(PORT, () => {
console.log(`[Express] Server running on ${PORT}`);
});
At this point I am all out of ideas, so any information would be much appreciated. I tried posting for help on SO, but got no help, and figured this was a more appropriate place to discuss this anyways.