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

Is there a way to get the original path? #34

Open
szimek opened this issue Feb 3, 2017 · 3 comments
Open

Is there a way to get the original path? #34

szimek opened this issue Feb 3, 2017 · 3 comments

Comments

@szimek
Copy link

szimek commented Feb 3, 2017

I got the following code:

app.use(history());
app.get('/index.html', (req, res) => {
  ...
}

Is there any way to get the original path (before rewrite) inside the handler for /index.html path?

@bripkens
Copy link
Owner

bripkens commented Feb 3, 2017

No, this doesn't exist, but should be easy to add. Feel free to open a PR and I'll check it out.

@tiagogm
Copy link

tiagogm commented Jan 4, 2018

Is this not already accessible in with req.originalUrl ?(http://expressjs.com/en/api.html#req.originalUrl)

This example seems to work for me

const express = require("express");
var history = require("connect-history-api-fallback");

const app = express()

app.use(history({ verbose: true, index: '/' }));
app.get("/", function(req, res) {
  console.log("Responding from", req.originalUrl);
  res.send("Hello World");
});
app.listen(3000);

@bripkens
Copy link
Owner

bripkens commented Jan 7, 2018

This works with express, yes, but please note the different values compared to req.url (see the docs).

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

3 participants