File tree Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Expand file tree Collapse file tree 1 file changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -24,7 +24,7 @@ replace_or_delete_in_index () {
2424 fi
2525}
2626
27- if [ " ${BASE_URL} " ]; then
27+ if [[ " ${BASE_URL} " != " / " ] ]; then
2828 sed -i " s|location / {|location $BASE_URL {|g" $NGINX_CONF
2929fi
3030
@@ -36,14 +36,20 @@ if [ "$SWAGGER_JSON_URL" ]; then
3636fi
3737
3838if [[ -f " $SWAGGER_JSON " ]]; then
39- cp -s " $SWAGGER_JSON " " $NGINX_ROOT "
4039 REL_PATH=" ./$( basename $SWAGGER_JSON ) "
4140
4241 if [[ -z " $SWAGGER_ROOT " ]]; then
4342 SWAGGER_ROOT=" $( dirname $SWAGGER_JSON ) "
4443 fi
4544
46- sed -i " s|#SWAGGER_ROOT|root $SWAGGER_ROOT ;|g" $NGINX_CONF
45+ if [[ " $BASE_URL " != " /" ]]
46+ then
47+ BASE_URL=$( echo $BASE_URL | sed ' s/\/$//' )
48+ sed -i \
49+ " s|#SWAGGER_ROOT|rewrite ^$BASE_URL (/.*)$ \$ 1 break;\n #SWAGGER_ROOT|" \
50+ $NGINX_CONF
51+ fi
52+ sed -i " s|#SWAGGER_ROOT|root $SWAGGER_ROOT /;|g" $NGINX_CONF
4753
4854 sed -i " s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH |g" $INDEX_FILE
4955 sed -i " s|http://example.com/api|$REL_PATH |g" $INDEX_FILE
You can’t perform that action at this time.
0 commit comments