How to use @commercetools-frontend/mc-dev-authentication - 6 common examples

To help you get started, weā€™ve selected a few @commercetools-frontend/mc-dev-authentication examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github commercetools / merchant-center-application-kit / packages / mc-scripts / config / webpack-dev-server.config.js View on Github external
before(app) {
    app.set('views', devAuthentication.views);
    app.set('view engine', devAuthentication.config.viewEngine);
    // This lets us open files from the runtime error overlay.
    app.use(errorOverlayMiddleware());
    // This service worker file is effectively a 'no-op' that will reset any
    // previous service worker registered for the same host:port combination.
    // We do this in development to avoid hitting the production cache if
    // it used the same host and port.
    // https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
    app.use(noopServiceWorkerMiddleware());
    app.use('/api/graphql', (request, response) => {
      response.statusCode = 400;
      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 "env.json" and point it to e.g. "https://mc.commercetools.com/api/graphql"`;
      const fakeApolloError = new Error(errorMessage);
      response.end(
        JSON.stringify({
          data: null,
github commercetools / merchant-center-application-kit / packages / mc-http-server / server.js View on Github external
// Explicitly check if the request is asking for the `index.html`
    // to avoid letting it be served by the static middleware without
    // the proper security headers.
    .use((request, response, next) => {
      if (request.url === '/' || request.url.startsWith('/index.html'))
        serverIndexMiddleware(request, response);
      else next();
    })
    // Try serving a static file that matches the url, otherwise go to
    // the next middleware (e.g. favicon.png)
    .use(express.static(options.paths.publicAssetsPath))
    // Catch all middleware to serve the `index.html` (for SPA routes)
    .use('*', serverIndexMiddleware);

  app.set('views', devAuthentication.views);
  app.set('view engine', devAuthentication.config.viewEngine);

  return app;
};
github commercetools / merchant-center-application-kit / packages / mc-scripts / config / webpack-dev-server.config.js View on Github external
before(app) {
    app.set('views', devAuthentication.views);
    app.set('view engine', devAuthentication.config.viewEngine);
    // This lets us open files from the runtime error overlay.
    app.use(errorOverlayMiddleware());
    // This service worker file is effectively a 'no-op' that will reset any
    // previous service worker registered for the same host:port combination.
    // We do this in development to avoid hitting the production cache if
    // it used the same host and port.
    // https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
    app.use(noopServiceWorkerMiddleware());
    app.use('/api/graphql', (request, response) => {
      response.statusCode = 400;
      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 "env.json" and point it to e.g. "https://mc.commercetools.com/api/graphql"`;
      const fakeApolloError = new Error(errorMessage);
      response.end(
        JSON.stringify({
github commercetools / merchant-center-application-kit / packages / mc-http-server / server.js View on Github external
.use(compression())
    // Explicitly check if the request is asking for the `index.html`
    // to avoid letting it be served by the static middleware without
    // the proper security headers.
    .use((request, response, next) => {
      if (request.url === '/' || request.url.startsWith('/index.html'))
        serverIndexMiddleware(request, response);
      else next();
    })
    // Try serving a static file that matches the url, otherwise go to
    // the next middleware (e.g. favicon.png)
    .use(express.static(options.paths.publicAssetsPath))
    // Catch all middleware to serve the `index.html` (for SPA routes)
    .use('*', serverIndexMiddleware);

  app.set('views', devAuthentication.views);
  app.set('view engine', devAuthentication.config.viewEngine);

  return app;
};
github commercetools / merchant-center-application-kit / packages / mc-scripts / config / webpack-dev-server.config.js View on Github external
app.use('/logout', (request, response, next) => {
      devAuthentication.routes.logout(response);

      if (localEnv.disableAuthRoutesOfDevServer) {
        next();
      } else {
        response.render('logout', { env: localEnv });
      }
    });
  },
github commercetools / merchant-center-application-kit / packages / mc-http-server / routes / logout.js View on Github external
module.exports = env => (request, response, next) => {
  if (!env.servedByProxy) {
    devAuthentication.routes.logout(response);
    response.render('logout', { env });
  } else {
    next();
  }
};

@commercetools-frontend/mc-dev-authentication

Authentication views when running webpack-dev-server in development mode

MIT
Latest version published 4 days ago

Package Health Score

87 / 100
Full package analysis