Conversation
Allow `endpointUrl` to be a relative path (e.g., `/_umami`) for proxied Umami instances served from a subdirectory. When using relative paths, the script `src` becomes relative and `data-host-url` is only set when explicitly provided.
|
@mschoeffmann wanna test this branch out? If not, I will probably setup Since this was wholly done by AI (other than me just guiding it), I’m not too comfortable making a release to NPM yet. |
There was a problem hiding this comment.
Pull request overview
This PR adds support for relative endpoint URLs (e.g., /_umami) to enable proxied Umami instances served from a subdirectory. The implementation handles relative paths by generating relative script src attributes and conditionally setting data-host-url only when explicitly provided.
Changes:
- Modified core logic to detect and handle relative vs. absolute endpoint URLs
- Added a new playground environment (
playground-relative) with comprehensive test coverage for the relative path feature - Updated CI workflow to test both absolute and relative URL configurations
Reviewed changes
Copilot reviewed 11 out of 13 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
| packages/astro-umami/src/index.ts | Core implementation: added isRelativePath() and buildScriptSrc() helpers; modified script generation logic to handle relative paths and conditionally set data-host-url |
| playground-relative/astro.config.ts | Configuration for relative path playground using /_umami endpoint |
| playground-relative/tests/relative-path.spec.ts | Comprehensive test suite verifying relative path behavior, script loading, and multi-domain scenarios |
| playground-relative/package.json | Dependencies and scripts for the relative path playground |
| playground-relative/playwright.config.ts | Playwright configuration for running tests on port 4322 |
| playground-relative/src/pages/index.astro | Simple test page for the relative path playground |
| playground-relative/tsconfig.json | TypeScript configuration for the playground |
| playground-relative/.gitignore | Standard gitignore entries for Astro and Playwright artifacts |
| pnpm-workspace.yaml | Added playground-relative to workspace packages |
| package.json | Updated test script to include both playgrounds |
| .github/workflows/test.yml | Modified CI workflow to build package once and test both playground environments |
Files not reviewed (1)
- pnpm-lock.yaml: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| await page.waitForTimeout(500); | ||
|
|
||
| // Verify requests use the page's host, not a hardcoded domain | ||
| const scriptRequest = requests.find(url => url.includes("script.js")); |
There was a problem hiding this comment.
Arrow function parameter should use parentheses around url for consistency with the project's style, especially since TypeScript benefits from explicit parameter typing.
| const scriptRequest = requests.find(url => url.includes("script.js")); | |
| const scriptRequest = requests.find((url) => url.includes("script.js")); |
Allow
endpointUrlto be a relative path (e.g.,/_umami) for proxied Umami instances served from a subdirectory. When using relative paths, the scriptsrcbecomes relative anddata-host-urlis only set when explicitly provided.Closes #139.
Full disclosure: Opus 4.5 “one-shotted” this PR. By that, I mean I gave it the problem description, it came up with a plan after I shepherded it a bit, and then I let it run free. All tests passed locally, let’s wait for CI to finish.