Node js не завершает запрос

auth.route.js:

const { Router } = require("express");
const ejs = require('ejs');
const { pages } = require("../lib/path");
const { readFileSync } = require('fs');
const router = Router();


router.get('/login', (req, res, next) => {
    const file = readFileSync(pages('login', 'index.html'), { encoding: "utf-8" })
    res.set("Connection", "close").end(file)
    res.socket.end()
    // res.shouldKeepAlive = false
    // next()
})
router.get('/style/login', (req, res, next) => {
    res.set("Connection", "close").sendFile(pages('login', 'style.css'))
    res.shouldKeepAlive = false
    res.socket.end()
    next()
})
module.exports = router

index.js:

const express = require('express');
const { sequelize } = require('./model/default_settings');
const api = require('./routes/api.route');
const auth = require('./routes/auth.route');
require('dotenv').config();

const app = express();
(async () => await sequelize.authenticate())().then(() => console.log("Successfully authentificated"));
app.use(express.json())
app.use(auth)
// auth.forEach(object => object["method"] === 'post' ? app.post(object["path"], object["func"]) : app.get(object["path"], object["func"]))
app.use(api)
// app.use(public)
const PORT = process.env.PORT | 3000;

app.listen(PORT, console.log(`We are working on ${PORT} port`));

// В файле .env надо SALT, SECRET_KEY и опционально PORT
module.exports = { app }

У меня есть такой код и при подключении он не завершает запрос и клиентская чать зависает. *Могу другие страницы тоже скинуть


Ответы (0 шт):