-
Notifications
You must be signed in to change notification settings - Fork 9.2k
Allow UI base url to be customizable #3957
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
Replaces #3054 |
| NGINX_WITH_BASE_URL="${NGINX_ROOT}${BASE_URL}" | ||
|
|
||
| mkdir -p ${NGINX_WITH_BASE_URL} | ||
| mv ${NGINX_ROOT}/*.* ${NGINX_WITH_BASE_URL}/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How does this behave when the container is run multiple times? I think it would nest the folder each time, i.e. /swagger then /swagger/swagger and so on.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state of the container is reset when you kill it, so each time you run the container, this script runs against a fresh file system, with all of the UI files in /usr/share/nginx/html.
I verified this locally by running it multiple times with the same base url, and a few times with the url switched back and forth to something else. Each time it worked as expected.
shockey
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Approved.
Thanks for the detail in your PR description, it was helpful 😄
|
Not sure why I didn't hit merge on Wednesday... Anyway, thanks for the contribution @mrparkers! |
Description
This change allows the user to pass a
BASE_URLenvironment variable when running the docker container in order to add a URL prefix to the UI.Motivation and Context
This change is needed if you need to run Swagger UI behind some reverse proxy that does path re-writes. This will enable you to add a URL prefix (such as
/swagger) to the UI and all of the CSS and JS files it needs, allowing you to use the UI at a new path instead of the root directory.How Has This Been Tested?
Build a local docker image from this branch:
Run the container normally (without the new environment variable) to make sure it is backward compatible:
Visiting
http://localhost:80confirms that it still works.Run the container with a new base url:
Visit
http://localhost:80/swaggerto see that it still works with the new URL.Types of changes
package.json)Checklist: