colyseus / proxy

🔀⚔ Proxy and Service Discovery for Colyseus 0.10 ~ 0.14 (Not recommended on 0.15+)
https://docs.colyseus.io/scalability/
MIT License
37 stars 25 forks source link

Enable CORS on the proxy #13

Open samuelnovaes opened 3 years ago

samuelnovaes commented 3 years ago

My Express app has CORS enabled, but it doesn't work becouse the proxy doesn't have the CORS enabled.

ilesmana commented 3 years ago

Hi @samuelnovaes , maybe you can follow my approach: add "Access-Control-Allow-Origin": "", and "Access-Control-Allow-Methods": "" to proxy.ts

update proxy.ts to this, build & run:

const httpServer = http.createServer((req, res) => { res.writeHead(301, { "Location": "https://" + req.headers['host']! + req.url, "Access-Control-Allow-Origin": "*", "Access-Control-Allow-Methods": "*" }); res.end(); });