fix(web): preserve HTTPS in sub-path redirects

Signed-off-by: XiaoSeS <87064762+XiaoSeS@users.noreply.github.com>
This commit is contained in:
XiaoSeS 2026-08-29 15:29:42 +08:00
parent 337d3d973d
commit e9e570133d
2 changed files with 6 additions and 1 deletions

View file

@ -86,6 +86,11 @@ if [ "$code" != '301' ]; then
echo "bare prefix must 301-redirect, got: $code" >&2
exit 1
fi
location=$(curl -s -o /dev/null -D - "$base/skillhub" | awk 'tolower($1) == "location:" { print $2 }' | tr -d '\r')
if [ "$location" != '/skillhub/' ]; then
echo "bare prefix redirect must stay relative to preserve an upstream HTTPS scheme, got: $location" >&2
exit 1
fi
docker rm -f "$name" >/dev/null 2>&1 || true

View file

@ -96,7 +96,7 @@ if [ "$SKILLHUB_WEB_BASE_PATH" = / ]; then
>"$routing_config"
else
base_path_without_trailing_slash=${SKILLHUB_WEB_BASE_PATH%/}
printf 'set $skillhub_forwarded_prefix %s;\n\nlocation = %s {\n return 301 %s/;\n}\n\nlocation ^~ %s {\n rewrite ^%s(.*)$ /$1 last;\n}\n' \
printf 'set $skillhub_forwarded_prefix %s;\n\nlocation = %s {\n absolute_redirect off;\n return 301 %s/;\n}\n\nlocation ^~ %s {\n rewrite ^%s(.*)$ /$1 last;\n}\n' \
"$base_path_without_trailing_slash" \
"$base_path_without_trailing_slash" \
"$base_path_without_trailing_slash" \