I’m hosting a Pokémon Showdown server on Glitch and I need SSL certificate on it. I tried to use this solution https://glitch.com/edit/#!/force-http-or-https but when I put the code in my config.js file, I get the error: "Cannot find module ‘express’ ". I reinstalled all modules using pnpm i but the error continues to appear. Does anyone know how can I fix it?
Hi @triad27, welcome to the Glitch Forums!
I’m assuming when you remove this code everything works as expected; if that’s the case it sounds like it might have something to do with how you’re requiring express in your config.js file. Can you provide your project name so we can take a look?
Hi @cori, thanks for the reply!
Exactly, without that code, the server works perfectly. I don’t know why but config.js is hidden from the editor tree, so I upload a txt version of it. I you want to take a look, this is the link to the project: https://glitch.com/edit/#!/comet-wing
Hey @triad27 the problem you’re running into is that the code that you’re trying to use relies on the “express” npm module but your package.json does require your project to install it, so it’s not available when your code gets to that point in config.js. You’d need to add something like
"express":"^4.16.4" to your package.json to have Express available to your code.
That said I’m a little confused here, because I see that when your project loads its app page (when you click on the “Show” link, or access http://comet-wing.glitch.me, for instance) it redirects you to a -80.psim.us address. The code you’re trying to use will only control comet-wing.glitch.me, and not any redirected address, and I also see that whatever server is hosting the .psim.us address doesn’t accept https connections. So I’m not quite sure what you’re trying to achieve, but I’m pretty sure that whatever it is, this code won’t do it.
Please let us know if you have any more questions or want to discuss what end result you’re hoping for so we can see if we can help you get there.
@cori I added “express”:"^4.16.4" in my package.json and put the code in config.js but, as you said, it doesn’t redirect the -80.psim.us adress.
Reading config.js, I found the instruction to allowing the access through HTTPS, using Let’s Encrypt script. Probably this is the only solution provided by the creator of this node.js server.
Thank you for the help!