Skip to content

feat: add support for relative endpoint URLs#152

Open
yeskunall wants to merge 3 commits intomainfrom
feat/relative-path-support
Open

feat: add support for relative endpoint URLs#152
yeskunall wants to merge 3 commits intomainfrom
feat/relative-path-support

Conversation

@yeskunall
Copy link
Owner

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.

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.

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.
@yeskunall
Copy link
Owner Author

@mschoeffmann wanna test this branch out? If not, I will probably setup pkg.pr.new and push a release that way.

Since this was wholly done by AI (other than me just guiding it), I’m not too comfortable making a release to NPM yet.

@yeskunall yeskunall requested a review from Copilot February 3, 2026 22:02
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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"));
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Arrow function parameter should use parentheses around url for consistency with the project's style, especially since TypeScript benefits from explicit parameter typing.

Suggested change
const scriptRequest = requests.find(url => url.includes("script.js"));
const scriptRequest = requests.find((url) => url.includes("script.js"));

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Umami in subdirectory of current host

1 participant