From 6d217b4f5a924239b61bbf8bcf5e45f7473d728a Mon Sep 17 00:00:00 2001 From: Gabe Kangas Date: Tue, 28 Nov 2023 23:58:29 -0800 Subject: [PATCH] fix(web): do not set nextjs rewrites on prod builds --- web/next.config.js | 54 ++++++++++++++++++++++++---------------------- 1 file changed, 28 insertions(+), 26 deletions(-) diff --git a/web/next.config.js b/web/next.config.js index 61b84303c..559fe48f0 100644 --- a/web/next.config.js +++ b/web/next.config.js @@ -52,32 +52,34 @@ module.exports = withPWA( return config; }, async rewrites() { - return [ - { - source: '/api/:path*', - destination: 'http://localhost:8080/api/:path*', // Proxy to Backend to work around CORS. - }, - { - source: '/hls/:path*', - destination: 'http://localhost:8080/hls/:path*', // Proxy to Backend to work around CORS. - }, - { - source: '/img/:path*', - destination: 'http://localhost:8080/img/:path*', // Proxy to Backend to work around CORS. - }, - { - source: '/logo', - destination: 'http://localhost:8080/logo', // Proxy to Backend to work around CORS. - }, - { - source: '/thumbnail.jpg', - destination: 'http://localhost:8080/thumbnail.jpg', // Proxy to Backend to work around CORS. - }, - { - source: '/customjavascript', - destination: 'http://localhost:8080/customjavascript', // Proxy to Backend to work around CORS. - }, - ]; + return process.env.NODE_ENV === 'development' + ? [ + { + source: '/api/:path*', + destination: 'http://localhost:8080/api/:path*', // Proxy to Backend to work around CORS. + }, + { + source: '/hls/:path*', + destination: 'http://localhost:8080/hls/:path*', // Proxy to Backend to work around CORS. + }, + { + source: '/img/:path*', + destination: 'http://localhost:8080/img/:path*', // Proxy to Backend to work around CORS. + }, + { + source: '/logo', + destination: 'http://localhost:8080/logo', // Proxy to Backend to work around CORS. + }, + { + source: '/thumbnail.jpg', + destination: 'http://localhost:8080/thumbnail.jpg', // Proxy to Backend to work around CORS. + }, + { + source: '/customjavascript', + destination: 'http://localhost:8080/customjavascript', // Proxy to Backend to work around CORS. + }, + ] + : null; }, pageExtensions: ['tsx'], }),