@@ -107,46 +107,50 @@ echo -e "\e[34m[Info] Using config file at: '$CONFIG_PATH'.\e[0m"
107107 done
108108}
109109
110-
111- # Update specifically NEXT_PUBLIC_DOMAIN_SUB_PATH w/o requiring a rebuild.
112- # Ultimately, the DOMAIN_SUB_PATH sets the `basePath` param in the next.config.mjs.
113- # Similar to above, we pass in a `BAKED_` sentinal value into next.config.mjs at build
114- # time. Unlike above, the `basePath` configuration is set in files other than just javascript
115- # code (e.g., manifest files, css files, etc.), so this section has subtle differences.
110+ # @nocheckin: This was interfering with the the `matcher` regex in middleware.ts,
111+ # causing regular expressions parsing errors when making a request. It's unclear
112+ # why exactly this was happening, but it's likely due to a bad replacement happening
113+ # in the `sed` command.
116114#
117- # @see: https://nextjs.org/docs/app/api-reference/next-config-js/basePath
118- # @see: https://phase.dev/blog/nextjs-public-runtime-variables/
119- {
120- if [ ! -z " $DOMAIN_SUB_PATH " ]; then
121- # If the sub-path is "/", this creates problems with certain replacements. For example:
122- # /BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH/_next/image -> //_next/image (notice the double slash...)
123- # To get around this, we default to an empty sub-path, which is the default when no sub-path is defined.
124- if [ " $DOMAIN_SUB_PATH " = " /" ]; then
125- DOMAIN_SUB_PATH=" "
126-
127- # Otherwise, we need to ensure that the sub-path starts with a slash, since this is a requirement
128- # for the basePath property. For example, assume DOMAIN_SUB_PATH=/bot, then:
129- # /BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH/_next/image -> /bot/_next/image
130- elif [[ ! " $DOMAIN_SUB_PATH " =~ ^/ ]]; then
131- DOMAIN_SUB_PATH=" /$DOMAIN_SUB_PATH "
132- fi
133- fi
134-
135- if [ ! -z " $DOMAIN_SUB_PATH " ]; then
136- echo -e " \e[34m[Info] DOMAIN_SUB_PATH was set to " $DOMAIN_SUB_PATH " . Overriding default path.\e[0m"
137- fi
138-
139- # Always set NEXT_PUBLIC_DOMAIN_SUB_PATH to DOMAIN_SUB_PATH (even if it is empty!!)
140- export NEXT_PUBLIC_DOMAIN_SUB_PATH=" $DOMAIN_SUB_PATH "
141-
142- # Iterate over _all_ files in the web directory, making substitutions for the `BAKED_` sentinal values
143- # with their actual desired runtime value.
144- find /app/packages/web -type f |
145- while read file; do
146- # @note: the leading "/" is required here as it is included at build time. See Dockerfile.
147- sed -i " s|/BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH|${NEXT_PUBLIC_DOMAIN_SUB_PATH} |g" " $file "
148- done
149- }
115+ # # Update specifically NEXT_PUBLIC_DOMAIN_SUB_PATH w/o requiring a rebuild.
116+ # # Ultimately, the DOMAIN_SUB_PATH sets the `basePath` param in the next.config.mjs.
117+ # # Similar to above, we pass in a `BAKED_` sentinal value into next.config.mjs at build
118+ # # time. Unlike above, the `basePath` configuration is set in files other than just javascript
119+ # # code (e.g., manifest files, css files, etc.), so this section has subtle differences.
120+ # #
121+ # # @see: https://nextjs.org/docs/app/api-reference/next-config-js/basePath
122+ # # @see: https://phase.dev/blog/nextjs-public-runtime-variables/
123+ # {
124+ # if [ ! -z "$DOMAIN_SUB_PATH" ]; then
125+ # # If the sub-path is "/", this creates problems with certain replacements. For example:
126+ # # /BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH/_next/image -> //_next/image (notice the double slash...)
127+ # # To get around this, we default to an empty sub-path, which is the default when no sub-path is defined.
128+ # if [ "$DOMAIN_SUB_PATH" = "/" ]; then
129+ # DOMAIN_SUB_PATH=""
130+
131+ # # Otherwise, we need to ensure that the sub-path starts with a slash, since this is a requirement
132+ # # for the basePath property. For example, assume DOMAIN_SUB_PATH=/bot, then:
133+ # # /BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH/_next/image -> /bot/_next/image
134+ # elif [[ ! "$DOMAIN_SUB_PATH" =~ ^/ ]]; then
135+ # DOMAIN_SUB_PATH="/$DOMAIN_SUB_PATH"
136+ # fi
137+ # fi
138+
139+ # if [ ! -z "$DOMAIN_SUB_PATH" ]; then
140+ # echo -e "\e[34m[Info] DOMAIN_SUB_PATH was set to "$DOMAIN_SUB_PATH". Overriding default path.\e[0m"
141+ # fi
142+
143+ # # Always set NEXT_PUBLIC_DOMAIN_SUB_PATH to DOMAIN_SUB_PATH (even if it is empty!!)
144+ # export NEXT_PUBLIC_DOMAIN_SUB_PATH="$DOMAIN_SUB_PATH"
145+
146+ # # Iterate over _all_ files in the web directory, making substitutions for the `BAKED_` sentinal values
147+ # # with their actual desired runtime value.
148+ # find /app/packages/web -type f |
149+ # while read file; do
150+ # # @note: the leading "/" is required here as it is included at build time. See Dockerfile.
151+ # sed -i "s|/BAKED_NEXT_PUBLIC_DOMAIN_SUB_PATH|${NEXT_PUBLIC_DOMAIN_SUB_PATH}|g" "$file"
152+ # done
153+ # }
150154
151155
152156# Run supervisord
0 commit comments