I am trying to add a POST route to my express app which is also using Colyseus.
Here is a demo code:
const app = express();
// This should add POST in the Allow request headers
app.use(cors());
app.options('*', cors());
// This is the Colyseus implementation
const gameServer = new Server({
server: createServer(app)
});
app.post('/signup', function (req, res) {
console.log(req.body);
console.log(res);
res.end();
})
When I make a POST request using Postman I receive error 405: Method not allowed
In the headers I see this:
Allow →GET, HEAD, OPTIONS
So it seems that POST does not work... When I remove Colyseus and only use the app, the POST requests work.
Any idea how to fix this, I'd be really grateful.