Sapper doesn't works on glitch

Hello,
Sapper, the SSR framework for svelte, doesn’t work with HMR on Glitch because it need another port.

I tried a lot of different things, but Sapper’s configuration needs at least two different ports (one for webpack and one for changes to hot reload)

And glitch only has one port opened (port 3000).

We absolutely need one more port opened on glitch to be able to develop more types of apps.

Please open another port !

You can run a development server, which the HMR can also run on.

No, you cannot run HMR directly on the developement server with sapper, you need two ports, sapper’s configuration asks for two different ports (–port and --dev-port), and if you type the same pourt, you get E_ADDRINUSE

So we need two ports opened on glitch

Hi there @superboss224!
Consider making a post in #feature-ideas asking for the ability to open more ports in Glitch containers to people can vote on the idea. Unless it is already a feature and I just don’t know about it :slight_smile:
Eddie

1 Like

Can you post your webpack config here?

Also take a look at this: https://github.com/rixo/svelte-loader-hot

You can have more ports by adding a proxy to your server. There is multiple methods. If you use express-http-proxy, here’s an example you can use easily :

const http = require('http')
const express = require('express');
const proxy = require("express-http-proxy");
const app = express();
const server = http.createServer(app).listen(process.env.PORT, () => {
  console.log('Listening...on port 3000');
});

app.use("/port/"+LocalPort, proxy("http://localhost:"+LocalPort));
//it redirects all requests to https://blabla.glitch.me/port/4000 to the internal port 4000  (it can be an other port, LocalPort is a variable holding the port number you want to use, in this case its value is 4000)

Then if you listen to the Port 4000 you will automatically listen to the internal port 4000 and it will work like a charm.

I had to use this for a Discord bot where the library required me to listen to a port for each Twitch streamer (I was listening to webhooks with twitch-channel, an NPM package). But to listen to multiple streamers I needed multiple ports. So I ultimately needed to proxy stuff.

2 Likes