Skip to content

Commit

Permalink
refactor(mc-scripts): adjust webpack dev server error message for /ap…
Browse files Browse the repository at this point in the history
…i/graphql route
  • Loading branch information
emmenko committed Jan 31, 2022
1 parent 71171d6 commit 504fe22
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
5 changes: 5 additions & 0 deletions .changeset/tricky-hornets-remain.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@commercetools-frontend/mc-scripts': patch
---

Adjust webpack dev server error message for `/api/graphql` endpoint.
7 changes: 2 additions & 5 deletions packages/mc-scripts/src/config/webpack-dev-server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,11 @@ module.exports = ({ allowedHost, contentBase, port, publicPath }) => ({
devServer.app.set('views', devAuthentication.views);
devServer.app.set('view engine', devAuthentication.config.viewEngine);
devServer.app.post('/api/graphql', (request, response) => {
response.statusCode = 400;
response.statusCode = 404;
response.setHeader('Content-Type', 'application/json');
const errorMessage = `This GraphQL endpoint is not available in ${process.env.NODE_ENV} mode, as it's not necessary. The menu configuration is loaded from the file "menu.json" (more info at https://www.npmjs.com/package/@commercetools-frontend/application-shell). In case you do need to test things out, you can pass a "mcProxyApiUrl" to your application config (in the "additionalEnv" properties) and point it to the production environment, for example for GCP-EU use "https://mc.europe-west1.gcp.commercetools.com/api/graphql".`;
const fakeApolloError = new Error(errorMessage);
response.end(
JSON.stringify({
data: null,
error: fakeApolloError,
message: `This GraphQL endpoint is only available in production in the [Merchant Center Proxy Router](https://docs.commercetools.com/custom-applications/concepts/merchant-center-proxy-router). Please check that you are not calling this endpoint in development mode.`,
})
);
});
Expand Down

0 comments on commit 504fe22

Please sign in to comment.