[SOLVED] Self hosted server on vps with ssl problems

So i have a vps on which i built and launched the self hosted server. When trying to authenticate in unity, i get these errors
image
if I try to access the server in web browser through http, it works, but with https it says the connection is insecure. Any ideas?

it looks like you should make the server accessible with https instead of http

https uses ssl compared to http that is plain text

Yeah, the problem is the whole vps server is set up with ssl properly. From webgl project, to phpmyadmin - everything is accessible through https. But the moralis server (node app) is only accessible through http.

1 Like

Okay, so after 6 frustrating hours i figured it out.
For any lost souls like me, here’s what I did.

run npm install https.
go to src/index.ts, replace http with https. Just import http from ‘https’ to import http from ‘https’ is enough.

Then add this somewhere above httpServer = http.createServer…
const options = {
key: fs.readFileSync(‘private.key’),
cert: fs.readFileSync(‘certificate.crt’),
};

instead of const httpServer = http.createServer(app);
replace with const httpServer = http.createServer(options,app);

and add your ssl key and certificate file (private.key and certificate.crt) in your server folder.
You’re good to go.

1 Like