Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,4 @@ lintPush.sh

test/cypress/screenshots
test/cypress/downloads
test/serve-this
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]

### Fixed

- Works when served from any base URL including a path (e.g. `https://www.example.com/your/preferred/path`) (#165).

## [1.4.0] - 2024-10-02

### Added
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ npm run build

The static build appears in directory `main/dist`.

This static build can be served on a webserver without modifications from the host's root path (e.g. `https://www.example.com`), or from any other path (e.g. `https://www.example.com/your/preferred/path`).

## Logging in

Some queries access data sources that are only readable by authenticated users. This requires you to log in.
Expand Down Expand Up @@ -359,6 +361,8 @@ For testing with the provided configuration file, we use [Cypress](https://www.c

The development version might be tested repeatedly during development.

Both the production version and the development version are tested from a non-empty path in the base URL.

### Testing the production version

1. Build the production version of the Web application and serve it:
Expand Down Expand Up @@ -400,10 +404,10 @@ The development version might be tested repeatedly during development.

The procedure is the same as for testing the production version, except for step 1, which is now:

1. Start the Web application in development mode:
1. Start the Web application in development mode, using a non-empty path in the base URL:

In directory `main`:

```bash
npm run dev
npm run dev-with-path
```
3 changes: 2 additions & 1 deletion main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
"lint:fix": "eslint . --ext js,jsx --report-unused-disable-directives --max-warnings 0 --fix",
"lint:markdown": "markdownlint-cli2",
"lint:markdown:fix": "markdownlint-cli2-fix",
"preview": "vite preview"
"preview": "vite preview",
"dev-with-path": "vite --base /random/path"
},
"dependencies": {
"@comunica/query-sparql": "^3.2.3",
Expand Down
3 changes: 2 additions & 1 deletion main/src/authenticationProvider/authenticationProvider.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ export default {
try {
await session.login({
oidcIssuer: idp,
redirectUrl: new URL("/", window.location.href).toString(),
// leading dot needed to run from any path
redirectUrl: new URL('.', window.location.href).toString(),
clientName: "Generic Data Viewer",
});
} catch (error) {
Expand Down
2 changes: 2 additions & 0 deletions main/vite.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,6 @@ export default defineConfig({
// necessary for crypto lib to work
global: 'globalThis'
},
// leading dot needed to run from any path
base: './'
})
2 changes: 1 addition & 1 deletion test/cypress.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export default defineConfig({
experimentalStudio: true,
experimentalRunAllSpecs: true,
defaultCommandTimeout: 10000, /* is OK for very slow computers */
baseUrl: 'http://localhost:5173',
baseUrl: 'http://localhost:5173/random/path',
video: false
},
});
2 changes: 1 addition & 1 deletion test/cypress/e2e/fetch-status.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("Fetch Status", () => {
cy.contains("button", "Authorize").click();
});

cy.url().should("eq", "http://localhost:5173/");
cy.url().should("eq", Cypress.config('baseUrl') + "/");

// Go to the mixed book query
cy.contains("For testing only").click();
Expand Down
4 changes: 2 additions & 2 deletions test/cypress/e2e/log-in.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ describe("Log in", () => {
cy.contains("button", "Authorize").click();
});

cy.url().should("eq", "http://localhost:5173/");
cy.url().should("eq", Cypress.config('baseUrl') + "/");
});

it("Log in with an invalid IDP issuer", () => {
Expand Down Expand Up @@ -83,7 +83,7 @@ describe("Log in", () => {
cy.contains("button", "Authorize").click();
});

cy.url().should("eq", "http://localhost:5173/");
cy.url().should("eq", Cypress.config('baseUrl') + "/");

cy.contains("General examples").click();
cy.contains("A secret list of my favorite books").click();
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/save-custom-queries-on-pod.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ describe("Saving custom queries on pods - logged in", () => {
cy.contains("button", "Authorize").click();
});

cy.url().should("eq", "http://localhost:5173/");
cy.url().should("eq", Cypress.config('baseUrl') + "/");

cy.visit("/#");
});
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/sources-from-indexfile.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ describe("Sources from index file", () => {
cy.contains("button", "Authorize").click();
});

cy.url().should("eq", "http://localhost:5173/");
cy.url().should("eq", Cypress.config('baseUrl') + "/");

//now try again
cy.contains("For testing only").click();
Expand Down
2 changes: 1 addition & 1 deletion test/cypress/e2e/sources-info.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ describe("Sources info", () => {
cy.contains("button", "Authorize").click();
});

cy.url().should("eq", "http://localhost:5173/");
cy.url().should("eq", Cypress.config('baseUrl') + "/");

cy.contains("General examples").click();
cy.contains("A secret list of my favorite books").click();
Expand Down
2 changes: 1 addition & 1 deletion test/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"version": "1.0.0",
"type": "module",
"scripts": {
"serve": "http-server -p 5173 ../main/dist",
"serve": "bash scripts/prepare-dir-to-serve.sh && http-server -p 5173 serve-this",
"test": "cypress run -b chrome",
"test:interactive": "cypress open -b chrome --e2e",
"prepare:pods": "npm run prepare:pods:accounts && npm run prepare:pods:data",
Expand Down
5 changes: 5 additions & 0 deletions test/scripts/prepare-dir-to-serve.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

rm -rf serve-this
mkdir -p serve-this/random
cp -ar ../main/dist serve-this/random/path