Fix(Docker): case where SWAGGER_ROOT in conjunction with BASE_URL does not work (#6147)
This commit is contained in:
@@ -24,7 +24,7 @@ replace_or_delete_in_index () {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
if [ "${BASE_URL}" ]; then
|
if [[ "${BASE_URL}" != "/" ]]; then
|
||||||
sed -i "s|location / {|location $BASE_URL {|g" $NGINX_CONF
|
sed -i "s|location / {|location $BASE_URL {|g" $NGINX_CONF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -36,14 +36,20 @@ if [ "$SWAGGER_JSON_URL" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$SWAGGER_JSON" ]]; then
|
if [[ -f "$SWAGGER_JSON" ]]; then
|
||||||
cp -s "$SWAGGER_JSON" "$NGINX_ROOT"
|
|
||||||
REL_PATH="./$(basename $SWAGGER_JSON)"
|
REL_PATH="./$(basename $SWAGGER_JSON)"
|
||||||
|
|
||||||
if [[ -z "$SWAGGER_ROOT" ]]; then
|
if [[ -z "$SWAGGER_ROOT" ]]; then
|
||||||
SWAGGER_ROOT="$(dirname $SWAGGER_JSON)"
|
SWAGGER_ROOT="$(dirname $SWAGGER_JSON)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sed -i "s|#SWAGGER_ROOT|root $SWAGGER_ROOT;|g" $NGINX_CONF
|
if [[ "$BASE_URL" != "/" ]]
|
||||||
|
then
|
||||||
|
BASE_URL=$(echo $BASE_URL | sed 's/\/$//')
|
||||||
|
sed -i \
|
||||||
|
"s|#SWAGGER_ROOT|rewrite ^$BASE_URL(/.*)$ \$1 break;\n #SWAGGER_ROOT|" \
|
||||||
|
$NGINX_CONF
|
||||||
|
fi
|
||||||
|
sed -i "s|#SWAGGER_ROOT|root $SWAGGER_ROOT/;|g" $NGINX_CONF
|
||||||
|
|
||||||
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
|
sed -i "s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH|g" $INDEX_FILE
|
||||||
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
|
sed -i "s|http://example.com/api|$REL_PATH|g" $INDEX_FILE
|
||||||
|
|||||||
Reference in New Issue
Block a user