GithubHelp home page GithubHelp logo

Comments (3)

Fanzoo avatar Fanzoo commented on June 25, 2024 1

I am having this same issue. I'd like serve to rewrite all routes to a single page except a specific route (or sub-routes). Is there any way to accomplish this?

from serve-handler.

laeijebor avatar laeijebor commented on June 25, 2024

For anyone else finding this issue - I had some success for my use case for making apple-app-site-association accessible (rewrites all routes for a react page using serve-handler, except for specified routes):

{
      rewrites: [
            {
                source: "/**!(apple-app-site-association)", destination: "/index.html"
            },
            {
                source: "/**/**", destination: "/index.html"
            },
            {
                source: "/apple-app-site-association",
                destination: "/apple-app-site-association.json"
            },

       ]
}
  • First entry rewrites all route endpoints except /apple-app-site-association to /index.html
  • Second rewrites everything in nested routes to /index.html
  • (Third one rewrites apple-app-site-association to a json file of the same name)

Hope this helps someone!

from serve-handler.

warren-bank avatar warren-bank commented on June 25, 2024

shameless self-promotion alert:
this feature is available in my @warren-bank/serve fork of serve

both redirects and rewrites support an optional boolean terminal attribute, which will prevent any additional rules from being processed.

something else to bear in mind:

  • the --single cli option in this fork is handled differently
    • upstream serve prepends a redirect that matches all request paths and redirects them to '/index.html'
    • this fork only redirects pages that would otherwise return a 404 status code

from serve-handler.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.