Answer the question
In order to leave comments, you need to log in
How to hang the opening of one file on all routes?
This is the code that doesn't work:
app.get('*', express.static(path.join(__dirname, '../public')))
/api/
. Answer the question
In order to leave comments, you need to log in
const express = require('express');
const path = require('path');
const app = express();
app.use('/public', express.static(path.join(__dirname, '/public'));
app.get('*', (req, res) => {
res.sendFile(path.join(__dirname, '/index.html'));
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question