Answer the question
In order to leave comments, you need to log in
Why does the server give an error when trying to go back a folder?
How to make a root directory, which is the parent folder of the folder in which we have a server file?
Such code throws an error, like others with attempts to get into the folder before.
const app = express();
app.use(express.static('../public'));
app.get('/', function (req: Request, res: Response) {
res.sendFile(`${__dirname}/../public/index.html`);
});
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question