jeudi 17 décembre 2020

https using node/express throwing ERR_EMPTY_RESPONSE

I have been trying to figure this out for a while now, but can't find anything that helps. My server code is pretty simple

const path = require('path');
const https = require('https');
const http = require('http');
const fs = require('fs');
const express = require('express');
const socketio = require('socket.io');
const e = require('express');
const { isObject } = require('util');
const { fstat } = require('fs');

var options = {
    cert: fs.readFileSync('./cert.pem'),
    key: fs.readFileSync('./privkey.pem'),
};

const app = express();
const server = https.createServer(options, app);
const io = socketio(server);

// Set static folder
app.use(express.static('public', { dotfiles: 'allow'}));

//app.use('/', express.static(('public', { dotfiles: 'allow'})));

const PORT = process.env.PORT || 80;

server.listen(PORT, "0.0.0.0", () => console.log(`Server running on port ${PORT}`));

I used certbot for the ssl, but when I go to my domain (works if I change to http) it throws ERR_EMPTY_RESPONSE. Any idea why this is happening? Thanks in advance.




Aucun commentaire:

Enregistrer un commentaire