File tree 1 file changed +9
-3
lines changed
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 () {
24
24
fi
25
25
}
26
26
27
- if [ " ${BASE_URL} " ]; then
27
+ if [[ " ${BASE_URL} " != " / " ] ]; then
28
28
sed -i " s|location / {|location $BASE_URL {|g" $NGINX_CONF
29
29
fi
30
30
@@ -36,14 +36,20 @@ if [ "$SWAGGER_JSON_URL" ]; then
36
36
fi
37
37
38
38
if [[ -f " $SWAGGER_JSON " ]]; then
39
- cp -s " $SWAGGER_JSON " " $NGINX_ROOT "
40
39
REL_PATH=" ./$( basename $SWAGGER_JSON ) "
41
40
42
41
if [[ -z " $SWAGGER_ROOT " ]]; then
43
42
SWAGGER_ROOT=" $( dirname $SWAGGER_JSON ) "
44
43
fi
45
44
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
47
53
48
54
sed -i " s|https://petstore.swagger.io/v2/swagger.json|$REL_PATH |g" $INDEX_FILE
49
55
sed -i " s|http://example.com/api|$REL_PATH |g" $INDEX_FILE
You can’t perform that action at this time.
0 commit comments