express.static: How to route ALL URLs to the 'dist' directory

Viewed 211

What I want is quite simple: All incoming URLs must return the 'dist' directory.

The basic code is :

const express = require('express');
const app = express();
app.use(express.static('dist'));
...

and of course this works for https://example.com and returns "Cannot GET /something" for https://example.com/something.

But I need all URLs returns the static dist content where my Vue.js app will parse the URL and do the job.

I know there's a lot of answers about serving a file using the app.get but that does not work for bundled files having names randomly created.

0 Answers
Related