Skip to content

🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.

🐛 fix: fix the Worker URL cross-origin issue (#9624)

peerless-herod379112d7485
diff --git a/next.config.ts b/next.config.ts
index f2cd5968397..82b5d8fe4a6 100644
--- a/next.config.ts
+++ b/next.config.ts
@@ -19,9 +19,11 @@ const standaloneConfig: NextConfig = {
outputFileTracingIncludes: { '*': ['public/**/*', '.next/static/**/*'] },
};
+const assetPrefix = process.env.NEXT_PUBLIC_ASSET_PREFIX;
+
const nextConfig: NextConfig = {
...(isStandaloneMode ? standaloneConfig : {}),
- assetPrefix: process.env.NEXT_PUBLIC_ASSET_PREFIX,
+ assetPrefix,
compiler: {
emotion: true,
},
@@ -309,6 +311,20 @@ const nextConfig: NextConfig = {
zipfile: false,
};
+ if (assetPrefix && (assetPrefix.startsWith('http://') || assetPrefix.startsWith('https://'))) {
+ // fix the Worker URL cross-origin issue
+ // refs: https://github.com/lobehub/lobe-chat/pull/9624
+ config.module.rules.push({
+ generator: {
+ // @see https://webpack.js.org/configuration/module/#rulegeneratorpublicpath
+ publicPath: '/_next/',
+ },
+ test: /worker\.ts$/,
+ // @see https://webpack.js.org/guides/asset-modules/
+ type: 'asset/resource',
+ });
+ }
+
return config;
},
};