Reputation: 186
I wonder how to a specific port according to the config service provider https://docs.nestjs.com/websockets/gateways ? For e.g, I want to listen to 8500 in my production environment but 8080 in my staging environment.
And how to allow cors on, because when I connect to the socket-server in the different domain it show has been blocked by CORS policy: Response to preflight request doesn't pass access control check: It does not have HTTP ok status
.
Upvotes: 4
Views: 3618
Reputation: 37
const options = {
cors: {
origin: ["example1.com", "example2.com"],
methods: ["GET", "POST"],
credentials: true
}
}
@WebSocketGateway(options)
Upvotes: 3