POST method not allowed in express app after passing it to Colyseus constructor

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.

Hey, still no answer to my issue. If anyone out there has any idea, I'd be really grateful.

Thanks! :)

Try reordering the declarations. ie

app.post('/signup', function (req, res) {
console.log(req.body);
console.log(res);
res.end();
})

// This is the Colyseus implementation
const gameServer = new Server({
server: createServer(app)
});

As far as I know express will process the hooks in the order they are declared so if colyseus is acting like a catch-all nothing after it will be processed. I am doing the same thing and I have all my HTTP handlers declared before the colyseus implementation.

Oh god, that actually solved it! Thank you very much! I thought I was going crazy :D