Skip to content

Middleware not updating during dev #15993

@bt64

Description

@bt64

Astro Info

Astro                    v6.0.6
Vite                     v7.3.1
Node                     v25.8.1
System                   macOS (arm64)
Package Manager          npm
Output                   static
Adapter                  @astrojs/node (v10.0.2)
Integrations             none

If this issue only occurs in one browser, which browser is a problem?

No response

Describe the Bug

Having a basic middleware like this, works fine:

import { defineMiddleware } from "astro:middleware";

export const onRequest = defineMiddleware((ctx, next) => {
  console.log("a");

  return next();
});

(the output is "a")

but if I change it to:

import { defineMiddleware } from "astro:middleware";

export const onRequest = defineMiddleware((ctx, next) => {
  console.log("b");

  return next();
});

The output is still "a", and a full reload of the dev server is needed to have it change to "b"

What's the expected result?

The expected result is not having to reload the dev server for every middleware change.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-vwqjqzv6?file=src%2Fmiddleware.ts

Participation

  • I am willing to submit a pull request for this issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    - P4: importantViolate documented behavior or significantly impacts performance (priority)pkg: astroRelated to the core `astro` package (scope)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions