Skip to content

Add adapters for redirects middleware #16

Description

@zachleat

Personally I’d get a lot of use out of having netlify redirects available in dev mode as an adapter

https://github.com/netlify/netlify-redirect-parser

Activity

  1. Snapstromegon commented on Mar 9, 2023

    @Snapstromegon
    Member

    I ran across this while building a SPA with 11ty and in these cases netlify redirects not working is really annoying.

    I also created a small reproduction of the issue here: https://github.com/Snapstromegon/netlify-eleventy-dev.

    This is a small, but annoying bug (and I don't know if netlify dev not working too is on this, or netlify-cli's side to fix). There is a workaround for static builds though, when you use netlify dev:

    Add these two scripts to your package.json:

    {
        "build:watch": "npx @11ty/eleventy --watch",
        "dev": "npx netlify-cli dev"
    }

    Add this to your netlify.toml

    [dev]
      framework = "#static"
      autoLaunch = false
      command = "npm run build:watch"

    This does not work for stuff that requires the use of the dev server like auto reloading, but it solves the base issue as a workaround.

    Btw: The redirect parser is now located here: https://github.com/netlify/build/tree/main/packages/redirect-parser

  2. marioortizmanero commented on Feb 28, 2025

    @marioortizmanero

    I also hit this issue, and haven't been able to replicate my _redirects with onRequest or middleware (which is undocumented but read about somewhere) with 11ty 3.0. Note that _redirects is also supported by Cloudflare Pages, which is what I use: https://developers.cloudflare.com/pages/configuration/redirects/

  3. zachleat commented on Mar 13, 2025

    @zachleat
    MemberAuthor

    I know that you were referring to middleware but I do want to link up onRequest docs: https://www.11ty.dev/docs/dev-server/#on-request-for-request-time-processing

    Most of the code for this is in @Snapstromegon’s PR here: https://github.com/11ty/eleventy-dev-server/pull/57/files

    I would love to have a demo repo for this (or an example on the docs) of how to wire this up with onRequest, for the record!

  4. added
    documentationImprovements or additions to documentation
    and removed
    enhancementNew feature or request
    on Mar 13, 2025
  5. added
    needs-votesA feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.
    on Mar 13, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentationneeds-votesA feature request on the backlog that needs upvotes or downvotes. Remove this label when resolved.

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions