fix order in express
This commit is contained in:
parent
919ac7012a
commit
9df7b8bc4f
11
src/index.ts
11
src/index.ts
|
|
@ -46,12 +46,11 @@ app.use(express.static(path.join(__dirname, '../public')));
|
|||
|
||||
app.use('/api', api);
|
||||
|
||||
// check if folder dist-vite exists
|
||||
if (fs.existsSync(path.join(__dirname, '../client/dist-vite'))) {
|
||||
app.use(express.static(path.join(__dirname, '../client/dist-vite')));
|
||||
} else {
|
||||
app.use(express.static(path.join(__dirname, '../client/dist')));
|
||||
}
|
||||
const staticDist = fs.existsSync(path.join(__dirname, '../client/dist-vite')) ? express.static(path.join(__dirname, '../client/dist-vite')) : express.static(path.join(__dirname, '../client/dist'));
|
||||
|
||||
app.use(staticDist);
|
||||
|
||||
app.get('*', staticDist);
|
||||
|
||||
app.listen(port, () => {
|
||||
console.log(`Server listening on port ${port}`);
|
||||
|
|
|
|||
Loading…
Reference in New Issue