1
0
Fork 0
mirror of https://github.com/terribleplan/next.js.git synced 2024-01-19 02:48:18 +00:00
next.js/examples/custom-server-proxy-websocket
JJ Kasper 5d779a0289 Add falling back to fetch based pinging for onDemandEntries (#6310)
After discussion, I added falling back to fetch based pinging when the WebSocket fails to connect. I also added an example of how to proxy the onDemandEntries WebSocket when using a custom server. Fixes: #6296
2019-02-15 22:22:21 +01:00
..
pages Add falling back to fetch based pinging for onDemandEntries (#6310) 2019-02-15 22:22:21 +01:00
genSSL.sh Add falling back to fetch based pinging for onDemandEntries (#6310) 2019-02-15 22:22:21 +01:00
next.config.js Add falling back to fetch based pinging for onDemandEntries (#6310) 2019-02-15 22:22:21 +01:00
package.json Add falling back to fetch based pinging for onDemandEntries (#6310) 2019-02-15 22:22:21 +01:00
README.md Add falling back to fetch based pinging for onDemandEntries (#6310) 2019-02-15 22:22:21 +01:00
server.js Add falling back to fetch based pinging for onDemandEntries (#6310) 2019-02-15 22:22:21 +01:00

Custom server with Proxying onDemandEntries WebSocket

How to use

Using create-next-app

Execute create-next-app with Yarn or npx to bootstrap the example:

npx create-next-app --example custom-server-proxy-websocket custom-server-proxy-websocket
# or
yarn create next-app --example custom-server-proxy-websocket custom-server-proxy-websocket

Download manually

Download the example:

curl https://codeload.github.com/zeit/next.js/tar.gz/canary | tar -xz --strip=2 next.js-canary/examples/custom-server-proxy-websocket
cd custom-server-proxy-websocket

Install it and run:

npm install
npm run ssl
npm run dev
# or
yarn
yarn ssl
yarn dev

The idea behind the example

The example shows how you can use SSL with a custom server and still use onDemandEntries WebSocket from Next.js using node-http-proxy and ExpressJS.