Skip to content

Commit

Permalink
fix: handle development proxy exceptions and show some context (#9839)
Browse files Browse the repository at this point in the history
<!--
  Q. Which branch should I use for my pull request?
  A. Use `master` branch (probably).

  Q. Which branch if my change is a bug fix for Gatsby v1?
  A. In this case, you should use the `v1` branch

  Q. Which branch if I'm still not sure?
  A. Use `master` branch. Ask in the PR if you're not sure and a Gatsby maintainer will be happy to help :)

  Note: We will only accept bug fixes for Gatsby v1. New features should be added to Gatsby v2.

  Learn more about contributing: https://www.gatsbyjs.org/docs/how-to-contribute/
-->
Closes #6771
  • Loading branch information
ValeraS authored and pieh committed Nov 9, 2018
1 parent 9b7dc7c commit b605ade
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion packages/gatsby/src/commands/develop.js
Expand Up @@ -155,7 +155,18 @@ async function startServer(program) {
const { prefix, url } = proxy
app.use(`${prefix}/*`, (req, res) => {
const proxiedUrl = url + req.originalUrl
req.pipe(request(proxiedUrl)).pipe(res)
req
.pipe(
request(proxiedUrl).on(`error`, err => {
const message = `Error when trying to proxy request "${
req.originalUrl
}" to "${proxiedUrl}"`

report.error(message, err)
res.status(500).end()
})
)
.pipe(res)
})
}

Expand Down

0 comments on commit b605ade

Please sign in to comment.