feat(playground): vite build uses relative asset paths instead of absolute #7816
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When attempting to run Cube behind a reverse proxy, it is only possible to set the base path for the API endpoints of Cube. This renders the playground unusable inside a non root base path.
For example when using /cube as a base path behind a reverse proxy, I can get the index.html to load, from /cube/index.html but then requests for assets are made to /some-asset.js instead of /cube/some-asset.js
Check List
Description of Changes Made (if issue reference is not provided)
Changes the path of bundled assets from absolute to relative.
For example
Becomes
This allows Cube playground to be run inside a subdirectory (behind a reverse proxy, for example).
Adding
base: './'
to the Vite config is the only change required for this.https://vitejs.dev/config/shared-options.html#base
As you can see in the docs, it's suggested for "embedded" applications, which I suppose encompasses those bundled in containers such as Cube's playground.
In terms of backwards compatibility, it should be fine as currently you must run it on the root path, so applications running on the root path will go from
/asset...
to./asset...
which resolves to/asset...
.Running
yarn build
in the packages/cubejs-playground directory yields the following