entrypoint fixes

This commit is contained in:
Santosh Tharu 2024-07-27 16:59:46 +05:45
parent b518b15559
commit f8aa276c36

View file

@ -1,6 +1,19 @@
#!/bin/sh
# replace /__ENTRYPOINT__ with the runtime-configured entrypoint
if [ "$ALLOWED_FRAME_URLS" = "" ]; then
# root entrypoint is handled differently from non-root, in particular
# - basePath="" rather than "/"
# - an extra redirect is added /x/ => /x -- but with root that would be // => / which is invalid
cp .next/routes-manifest.json .next/routes-manifest.json.in
jq -rc '.basePath = ""
| .redirects = [
.redirects
| .[]
| select((.source == "/__ENTRYPOINT__/" and .destination == "/__ENTRYPOINT__") | not)
]' .next/routes-manifest.json.in > .next/routes-manifest.json
fi
escaped_frame_urls=$(echo "$ALLOWED_FRAME_URLS" | sed 's/\//\\\//g')
echo "Replacing /__ENTRYPOINT__ in all .next file..."