From 6b598b24018af5ea569fa6447d9c6e3593c5e3c9 Mon Sep 17 00:00:00 2001 From: "Fred K. Schott" Date: Wed, 17 Nov 2021 12:40:30 -0800 Subject: [PATCH] fix middleware order (#1865) --- .changeset/heavy-boxes-deliver.md | 5 +++++ packages/astro/src/core/dev/index.ts | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) create mode 100644 .changeset/heavy-boxes-deliver.md diff --git a/.changeset/heavy-boxes-deliver.md b/.changeset/heavy-boxes-deliver.md new file mode 100644 index 0000000000..a5d0e5e3f8 --- /dev/null +++ b/.changeset/heavy-boxes-deliver.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix middleware order diff --git a/packages/astro/src/core/dev/index.ts b/packages/astro/src/core/dev/index.ts index e1fe59a8f7..56808fd784 100644 --- a/packages/astro/src/core/dev/index.ts +++ b/packages/astro/src/core/dev/index.ts @@ -83,8 +83,8 @@ export class AstroDevServer { // Setup the dev server and connect it to Vite (via middleware) this.viteServer = await this.createViteServer(); - this.app.use((req, res, next) => this.handleRequest(req, res, next)); this.app.use(this.viteServer.middlewares); + this.app.use((req, res, next) => this.handleRequest(req, res, next)); this.app.use((req, res, next) => this.renderError(req, res, next)); // Listen on port (and retry if taken)