Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running wss in Nextjs #1786

Closed
hypo-thesis opened this issue Aug 21, 2020 · 2 comments
Closed

Running wss in Nextjs #1786

hypo-thesis opened this issue Aug 21, 2020 · 2 comments

Comments

@hypo-thesis
Copy link

I was unable to find a work around to make my ws into wss on Nextjs. As on Express I can

const server = https.createServer({
  cert: fs.readFileSync('/www/wwwroot/domain/cert/cert.pem'),
  key: fs.readFileSync('/www/wwwroot/domain/cert/key.pem')
});
const wss = new Websocket.Server({ server })
server.listen(8082)

I do not know how to integrate the pem certificates in Nextjs.
ws works fine with nextjs but I am not sure how I can introduce the ssl to work with ws with nextjs.
Can you give me some direction to use wss intead of ws?

@lpinca
Copy link
Member

lpinca commented Aug 21, 2020

See https://nextjs.org/docs/advanced-features/custom-server. Replace const { createServer } = require('http') with const { createServer } = require('https') and use the options object as described here https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener.

@lpinca
Copy link
Member

lpinca commented Aug 21, 2020

(This is not an issue in the library)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants