Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NextJs] Fix "debug module not found" error in redirects middleware #1045

Merged
merged 2 commits into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ const { constants } = require('@sitecore-jss/sitecore-jss-nextjs');
const disconnectedServerUrl = `http://localhost:${process.env.PROXY_PORT || 3042}/`;
const isDisconnected = process.env.JSS_MODE === constants.JSS_MODE.DISCONNECTED;

/**
* @param {import('next').NextConfig} nextConfig
*/
const disconnectedPlugin = (nextConfig = {}) => {
if (!isDisconnected) {
return nextConfig;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @param {import('next').NextConfig} nextConfig
*/
const styleguidePlugin = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
i18n: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { NextRequest, NextResponse } from 'next/server';
import { RedirectsMiddleware } from '@sitecore-jss/sitecore-jss-nextjs/edge';
import config from 'temp/config';
import { MiddlewarePlugin } from '..';
import nextConfig from '../../../../next.config';

class RedirectsPlugin implements MiddlewarePlugin {
private redirectsMiddleware: RedirectsMiddleware;
Expand All @@ -13,7 +12,9 @@ class RedirectsPlugin implements MiddlewarePlugin {
endpoint: config.graphQLEndpoint,
apiKey: config.sitecoreApiKey,
siteName: config.jssAppName,
locales: nextConfig().i18n.locales,
// These are all the locales you support in your application.
// These should match those in your next.config.js (i18n.locales).
locales: ['en'],
});
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @param {import('next').NextConfig} nextConfig
*/
const robotsPlugin = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
async rewrites() {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @param {import('next').NextConfig} nextConfig
*/
const sitemapPlugin = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
async rewrites() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const plugins = require('./src/temp/next-config-plugins') || {};

const publicUrl = getPublicUrl();

/**
* @type {import('next').NextConfig}
*/
const nextConfig = {
// Set assetPrefix to our public URL
assetPrefix: publicUrl,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @param {import('next').NextConfig} nextConfig
*/
const edgePlugin = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack: (config, options) => {
Expand All @@ -6,7 +9,7 @@ const edgePlugin = (nextConfig = {}) => {
// Point the Edge compiler in the right direction for 3rd-party module browser bundles.

// debug
config.resolve.alias.debug = require.resolve('debug/src/browser');
config.resolve.alias['debug'] = require.resolve('debug/src/browser');

// graphql-request
config.resolve.alias['cross-fetch'] = require.resolve('cross-fetch/dist/browser-ponyfill');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/**
* @param {import('next').NextConfig} nextConfig
*/
const graphqlPlugin = (nextConfig = {}) => {
return Object.assign({}, nextConfig, {
webpack: (config, options) => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const path = require('path');

const CWD = process.cwd();

/**
* @param {import('next').NextConfig} nextConfig
*/
const monorepoPlugin = (nextConfig = {}) => {
return withTM(Object.assign({}, nextConfig, {
webpack: (config, options) => {
Expand Down