Skip to content

Commit

Permalink
add possibility to deploy under the URI prefix
Browse files Browse the repository at this point in the history
  • Loading branch information
vadym-serdiuk committed Dec 26, 2023
1 parent bb6e589 commit a707aad
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ RUN --mount=type=bind,target=./package.json,src=./superset-frontend/package.json

COPY ./superset-frontend ./
# This seems to be the most expensive step
ARG ASSET_BASE_URL=""
RUN npm run ${BUILD_CMD}

######################################################################
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/assets/staticPages/404.html
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ <h1>Page not found</h1>
Sorry, we cannot find the page you are looking for. You may have
mistyped the address or the page may have moved.
</p>
<a href="/" class="button">Back to home</a>
<a href="<%= prefix %>/" class="button">Back to home</a>
</section>
<img
alt="404"
Expand Down
2 changes: 1 addition & 1 deletion superset-frontend/src/assets/staticPages/500.html
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ <h1>Internal server error</h1>
Sorry, something went wrong. We are fixing the mistake now. Try again
later or go back to home.
</p>
<a href="/" class="button">Back to home</a>
<a href="<%= prefix %>/" class="button">Back to home</a>
</section>
<img
alt="500"
Expand Down
7 changes: 4 additions & 3 deletions superset-frontend/src/utils/export.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import parseCookie from 'src/utils/parseCookie';
import rison from 'rison';
import shortid from 'shortid';
import { withPrefix } from './routeUtils';

export default function handleResourceExport(
resource: string,
Expand All @@ -27,9 +28,9 @@ export default function handleResourceExport(
interval = 200,
): void {
const token = shortid.generate();
const url = `/api/v1/${resource}/export/?q=${rison.encode(
ids,
)}&token=${token}`;
const url = withPrefix(

Check warning on line 31 in superset-frontend/src/utils/export.ts

View check run for this annotation

Codecov / codecov/patch

superset-frontend/src/utils/export.ts#L31

Added line #L31 was not covered by tests
`/api/v1/${resource}/export/?q=${rison.encode(ids)}&token=${token}`,
);

// create new iframe for export
const iframe = document.createElement('iframe');
Expand Down
6 changes: 6 additions & 0 deletions superset-frontend/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,18 @@ const plugins = [
// static pages
new HtmlWebpackPlugin({
template: './src/assets/staticPages/404.html',
templateParameters: {
prefix: ASSET_BASE_URL,
},
inject: true,
chunks: [],
filename: '404.html',
}),
new HtmlWebpackPlugin({
template: './src/assets/staticPages/500.html',
templateParameters: {
prefix: ASSET_BASE_URL,
},
inject: true,
chunks: [],
filename: '500.html',
Expand Down

0 comments on commit a707aad

Please sign in to comment.