Closed psteinroe closed 4 years ago
Hey,
fetch isn't available during SSR. It looks like your react components are using fetch
somewhere.
You might want to look into https://www.gatsbyjs.org/docs/using-client-side-only-packages/.
Sorry to hear you're running into an issue. To help us best begin debugging the underlying cause, it is incredibly helpful if you're able to create a minimal reproduction. This is a simplified example of the issue that makes it clear and obvious what the issue is and how we can begin to debug it.
If you're up for it, we'd very much appreciate if you could provide a minimal reproduction and we'll be able to take another look.
Thanks for using Gatsby! 💜
Thanks for the fast response!!
I guess its the Shopify Buy Button which is using fetch. I have had a similar error with the firebase SDK and I solved it by excluding its injection during the build phase. Would a similar approach be possible for the Shopify buy button sdk? Are there any pros / cons compared to the suggestions in the docs?
// gatsby-ssr.js
exports.onCreateWebpackConfig = ({
stage,
actions,
getConfig,
}) => {
if (stage === "build-html") {
actions.setWebpackConfig({
externals: getConfig().externals.concat(function(context, request, callback) {
const regex = /^@?firebase(\/(.+))?/
// exclude firebase products from being bundled, so they will be loaded using require() at runtime.
if (regex.test(request)) {
return callback(null, "umd " + request)
}
callback()
}),
})
}
}
it has an example with the shopify buy button. I would suggest going for React-loadable or componentDidMount.
Thanks guys - can be closed!
Hi everyone,
I suddenly get the following error when building, but the build does not fail and nothing seems to be wrong with the output:
Steps to reproduce
I can not really say how to reproduce as this error now occurs after only a minor change in the code (I deleted a page).
Environment