Skip to content

Commit

Permalink
fix(mc-scripts): local login dev for internal usage (#2626)
Browse files Browse the repository at this point in the history
  • Loading branch information
emmenko committed Jun 3, 2022
1 parent f0d6365 commit eea4f5f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 7 deletions.
6 changes: 6 additions & 0 deletions .changeset/fuzzy-comics-visit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@commercetools-frontend/mc-dev-authentication': patch
'@commercetools-frontend/mc-scripts': patch
---

Fix dev middleware usage for local login flow (internal usage only)"
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ function createMcDevAuthenticationMiddleware(
if (request.originalUrl === '/api/graphql') {
response.statusCode = 404;
response.setHeader('Content-Type', 'application/json');
response.end(
response.send(
JSON.stringify({
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 All @@ -42,7 +42,7 @@ function createMcDevAuthenticationMiddleware(
if (isDevAuthenticationMiddlewareDisabled) {
next();
} else {
response.end(htmlLogin);
response.send(htmlLogin);
}
return;
}
Expand All @@ -52,7 +52,7 @@ function createMcDevAuthenticationMiddleware(
if (isDevAuthenticationMiddlewareDisabled) {
next();
} else {
response.end(htmlLogin);
response.send(htmlLogin);
}
return;
}
Expand All @@ -62,7 +62,7 @@ function createMcDevAuthenticationMiddleware(
if (isDevAuthenticationMiddlewareDisabled) {
next();
} else {
response.end(htmlLogout);
response.send(htmlLogout);
}
return;
}
Expand Down
4 changes: 1 addition & 3 deletions packages/mc-scripts/src/config/webpack-dev-server.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,12 @@ module.exports = ({ port, publicPath }) => ({
hot: true,
https: false,
port,
// Enable HTTPS if the HTTPS environment variable is set to 'true'
// `proxy` is run between `before` and `after` `webpack-dev-server` hooks
setupMiddlewares(middlewares, devServer) {
if (!devServer) {
throw new Error('webpack-dev-server is not defined');
}

middlewares.push(createMcDevAuthenticationMiddleware(applicationConfig));
devServer.app.use(createMcDevAuthenticationMiddleware(applicationConfig));

return middlewares;
},
Expand Down

1 comment on commit eea4f5f

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deploy preview for merchant-center-application-kit ready!

✅ Preview
https://merchant-center-application-ptaqohic7-commercetools.vercel.app

Built with commit eea4f5f.
This pull request is being automatically deployed with vercel-action

Please sign in to comment.