vite-express
Advanced tools
Comparing version 0.11.0 to 0.11.1
@@ -173,3 +173,5 @@ 'use strict'; | ||
const config = yield getViteConfig(); | ||
app.get("/*", (req, res, next) => __awaiter(this, void 0, void 0, function* () { | ||
app.use(config.base, (req, res, next) => __awaiter(this, void 0, void 0, function* () { | ||
if (req.method !== "GET") | ||
return next(); | ||
if (isIgnoredPath(req.path, req)) | ||
@@ -193,6 +195,7 @@ return next(); | ||
const distPath = yield getDistPath(); | ||
app.use("*", (req, res, next) => { | ||
if (isIgnoredPath(req.baseUrl, req)) | ||
const config = yield getViteConfig(); | ||
app.use(config.base, (req, res, next) => { | ||
if (isIgnoredPath(req.path, req)) | ||
return next(); | ||
const indexPath = findClosestIndexToRoot(req.originalUrl, distPath); | ||
const indexPath = findClosestIndexToRoot(req.path, distPath); | ||
if (indexPath === undefined) | ||
@@ -199,0 +202,0 @@ return next(); |
{ | ||
"name": "vite-express", | ||
"version": "0.11.0", | ||
"version": "0.11.1", | ||
"main": "dist/main.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/main.d.ts", |
@@ -218,5 +218,12 @@ # ⚡ Vite + Express | ||
Why `nested/subroute/my/secret/path/index.html` isn't considered? Because it needs to have a trailing `/`. That's how Vite is doing it. | ||
If you want, you can always use express [redirect][express-redirect] to add this trailing slash at the end. | ||
Please remember that you still have to [configure `Vite`][vite-multipage] so that it will resolve all these files correctly in its build step. | ||
```js | ||
app.get('^nested/subroute/my/secret/path$', (_, res) => { | ||
res.redirect("nested/subroute/my/secret/path/") | ||
}); | ||
``` | ||
⚠️ Please remember that you still have to [configure `Vite`][vite-multipage] so that it will resolve all these files correctly in its build step. | ||
## 🤖 Transforming HTML | ||
@@ -389,2 +396,3 @@ | ||
[express-request]: https://expressjs.com/en/api.html#req | ||
[express-redirect]: https://expressjs.com/en/api.html#res.redirect | ||
[vite-config]: https://vitejs.dev/config/ | ||
@@ -391,0 +399,0 @@ [root]: https://vitejs.dev/config/shared-options.html#root |
34063
283
401