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

Exceptions for particular routes #47

Closed
ramazan793 opened this issue Dec 24, 2017 · 3 comments
Closed

Exceptions for particular routes #47

ramazan793 opened this issue Dec 24, 2017 · 3 comments

Comments

@ramazan793
Copy link

ramazan793 commented Dec 24, 2017

How to not rewrite particular routes like /auth/google?
Is there a way to add own exclusion for some routes?

My temporary solution - use history only for specified routes, not for all app like app.use(history)

@superzw
Copy link

superzw commented Jan 26, 2018

I also want to know that.

@bripkens
Copy link
Owner

The result of calling:

history({
  rewrites: [
    { from: /\/soccer/, to: '/soccer.html'}
  ]
})

is just a function of the form (req, res, next) => void. You can create a wrapper around history to achieve what you want. Adding exception support is out of scope for this module.

@nyngwang
Copy link

nyngwang commented Feb 23, 2024

To @ramazan793 @superzw:

Hi, I know it's probably too late, but it's achievable :)

historyApiFallback: {
  verbose: true,
  rewrites: [
    { from: /^\/(public|build)\//, to: context => context.parsedUrl.pathname },
    { from: /^(?!\/(public|build)\/)/, to: '/' },
  ]
},

This way, only those URL starting with ^/public/.* or ^/build/.* will be excluded from redirecting to /. This is my log using webpack-dev-server:

Rewriting GET /buisdlfusdf to /
Rewriting GET /test to /
Rewriting GET /public/css/ to /public/css/
Rewriting GET /build/vendors/ to /build/vendors/

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

No branches or pull requests

4 participants