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

fix(gatsby): always respond with index html without checking path #11400

Merged
merged 2 commits into from
Jan 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion packages/gatsby/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,6 @@
"null-loader": "^0.1.1",
"opentracing": "^0.14.3",
"optimize-css-assets-webpack-plugin": "^5.0.1",
"parse-filepath": "^1.0.1",
"physical-cpu-count": "^2.0.0",
"postcss-flexbugs-fixes": "^3.0.0",
"postcss-loader": "^2.1.3",
Expand Down
20 changes: 5 additions & 15 deletions packages/gatsby/src/commands/develop.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ const express = require(`express`)
const graphqlHTTP = require(`express-graphql`)
const graphqlPlayground = require(`graphql-playground-middleware-express`)
.default
const parsePath = require(`parse-filepath`)
const request = require(`request`)
const rl = require(`readline`)
const webpack = require(`webpack`)
Expand Down Expand Up @@ -187,20 +186,11 @@ async function startServer(program) {

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

/**
Expand Down