Skip to content

gatsby develop page reloads fail if URL ends with a SemVer range #3164

@danoc

Description

@danoc

Hi! This is a weird one.

gatsby develop uses parse-filepath to grab the extension from a URL and serve public/index.html:

// Render an HTML page and serve it.
app.use((req, res, next) => {
const parsedPath = parsePath(req.path)
if (parsedPath.extname === `` || parsedPath.extname.startsWith(`.html`)) {
res.sendFile(directoryPath(`public/index.html`), err => {
if (err) {
res.status(500).end()
}
})
} else {
next()
}
})

Line 149 incorrectly fails for our URLs that include a SemVer range at the end.

This happens because parse-filepath believes that a URL like /tp-ui-react-button/1.6.3/ has a file extension of .3:

image

This causes the development server to throw a 404 when attempting to reload the page: "Cannot GET /tp-ui-react-button/1.6.3/". The reloads work when I use URLs that end in index.html


I'll likely work around this by wrapping gatsby-link to append index.html to URLs on development.

Any thoughts on adding parsedPath.path.endsWith('/') to the conditional on L149? I can make the change if y'all would like.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions