SIGN IN SIGN UP
socketio / socket.io UNCLAIMED

Realtime application framework (Node.JS server)

0 0 0 TypeScript

feat: use the cors module to handle cross-origin requests

We'll now rely on the standard cors module (https://github.com/expressjs/cors),
instead of the custom implementation that is error-prone and not
really user-friendly.

Breaking change: the handlePreflightRequest option is removed by the
change.

Before:

```
new Server({
  handlePreflightRequest: (req, res) => {
    res.writeHead(200, {
      "Access-Control-Allow-Origin": 'https://example.com',
      "Access-Control-Allow-Methods": 'GET',
      "Access-Control-Allow-Headers": 'Authorization',
      "Access-Control-Allow-Credentials": true
    });
    res.end();
  }
})
```

After:

```
new Server({
  cors: {
    origin: "https://example.com",
    methods: ["GET"],
    allowedHeaders: ["Authorization"],
    credentials: true
  }
})
```
D
Damien Arrachequesne committed
61b949259ed966ef6fc8bfd61f14d1a2ef06d319
Parent: bafe684