Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🐛 [Bug] v5.1.1 - Can't load the middleware. #12819

Closed
1 task
JakiChen opened this issue Dec 23, 2024 · 2 comments
Closed
1 task

🐛 [Bug] v5.1.1 - Can't load the middleware. #12819

JakiChen opened this issue Dec 23, 2024 · 2 comments
Labels
needs repro Issue needs a reproduction

Comments

@JakiChen
Copy link

JakiChen commented Dec 23, 2024

Astro Info

Astro                    v5.1.1
Node                     v20.18.0
System                   macOS (x64)
Package Manager          yarn
Output                   server
Adapter                  @astrojs/vercel
Integrations             astro-favicons
                         @storyblok/astro
                         astro-robots
                         @astrojs/sitemap

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

No response

Describe the Bug

The issue occurs when astro-favicons are a development dependency, but as a dependency, everything works fine.

What causes this?
截屏2024-12-23 22 53 31

What's the expected result?

The middleware of astro-favicons should work fine regardless of whether it is a development dependency or a dependency Because in "astro": "^4.16.14", complex projects (useful to middleware, restApi, storyblok, etc.) will work fine

Link to Minimal Reproducible Example

See https://github.com/jakichen/boilerplates-vercel

Participation

  • I am willing to submit a pull request for this issue.
@github-actions github-actions bot added the needs triage Issue needs to be triaged label Dec 23, 2024
@ematipico ematipico added the needs repro Issue needs a reproduction label Dec 23, 2024
Copy link
Contributor

Hello @JakiChen. Please provide a minimal reproduction using a GitHub repository or StackBlitz. Issues marked with needs repro will be closed if they have no activity within 3 days.

@github-actions github-actions bot removed the needs triage Issue needs to be triaged label Dec 23, 2024
@dreamstar-enterprises
Copy link

dreamstar-enterprises commented Dec 28, 2024

I have the same issue following this example:
https://docs.astro.build/en/guides/middleware/
Middleware just wont load in 5.1.1

{
  "name": "Error",
  "code": "ERR_MODULE_NOT_FOUND",
  "runnerError": {}
}

Also your docs have errors I believe (no context in the return statement before locals):


export function onRequest (context, next) {
    // intercept data from a request
    // optionally, modify the properties in `locals`
    context.locals.user.name = "John Wick";
    context.locals.welcomeTitle = () => {
        return "Welcome back " + locals.user.name;
    };

    // return a Response or the result of calling `next()`
    return next();
};

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
needs repro Issue needs a reproduction
Projects
None yet
Development

No branches or pull requests

3 participants