Skip to content

Fix VitePress base path for phenotype.space#837

Open
KooshaPari wants to merge 2 commits into
mainfrom
fix/asset-base-path
Open

Fix VitePress base path for phenotype.space#837
KooshaPari wants to merge 2 commits into
mainfrom
fix/asset-base-path

Conversation

@KooshaPari

@KooshaPari KooshaPari commented Jun 27, 2026

Copy link
Copy Markdown
Owner

User description

Summary

  • Add docs/.vitepress/resolve-base.mjs shared resolver
  • Remove GITHUB_ACTIONS-based subpath detection from VitePress config

Root cause

Builds set base: '/AgilePlus/' while agileplus.phenotype.space serves at /, so CSS loaded from /AgilePlus/assets/... 404s.

Test plan

  • Redeploy agileplus.phenotype.space
  • Confirm homepage stylesheet uses /assets/... and returns 200

Made with Cursor


CodeAnt-AI Description

Fix docs asset URLs on custom-domain and GitHub Pages builds

What Changed

  • Docs now choose the correct base path for the site instead of relying on GitHub Actions detection
  • Custom-domain deployments serve assets from the site root, so styles and other files load from /assets/...
  • GitHub Pages deployments still use the repository subpath, and explicit base settings are respected when provided

Impact

✅ Fewer broken styles on custom-domain docs sites
✅ Fewer 404s for docs assets
✅ Correct asset loading on GitHub Pages and local builds

💡 Usage Guide

Checking Your Pull Request

Every time you make a pull request, our system automatically looks through it. We check for security issues, mistakes in how you're setting up your infrastructure, and common code problems. We do this to make sure your changes are solid and won't cause any trouble later.

Talking to CodeAnt AI

Got a question or need a hand with something in your pull request? You can easily get in touch with CodeAnt AI right here. Just type the following in a comment on your pull request, and replace "Your question here" with whatever you want to ask:

@codeant-ai ask: Your question here

This lets you have a chat with CodeAnt AI about your pull request, making it easier to understand and improve your code.

Example

@codeant-ai ask: Can you suggest a safer alternative to storing this secret?

Preserve Org Learnings with CodeAnt

You can record team preferences so CodeAnt AI applies them in future reviews. Reply directly to the specific CodeAnt AI suggestion (in the same thread) and replace "Your feedback here" with your input:

@codeant-ai: Your feedback here

This helps CodeAnt AI learn and adapt to your team's coding style and standards.

Example

@codeant-ai: Do not flag unused imports.

Retrigger review

Ask CodeAnt AI to review the PR again, by typing:

@codeant-ai: review

Check Your Repository Health

To analyze the health of your code repository, visit our dashboard at https://app.codeant.ai. This tool helps you identify potential issues and areas for improvement in your codebase, ensuring your repository maintains high standards of code health.

KooshaPari and others added 2 commits June 26, 2026 18:13
Drop GITHUB_ACTIONS-based subpath detection and resolve base via PHENOTYPE_CUSTOM_DOMAIN or explicit GITHUB_PAGES so assets serve from `/assets/` on subdomain roots.

Co-authored-by: Cursor <cursoragent@cursor.com>
Use env-driven base resolution instead of GITHUB_ACTIONS heuristics so phenotype.space builds emit root-relative asset URLs.

Co-authored-by: Cursor <cursoragent@cursor.com>
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@codeant-ai

codeant-ai Bot commented Jun 27, 2026

Copy link
Copy Markdown

CodeAnt AI is reviewing your PR.

@codeant-ai

codeant-ai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Thanks for using CodeAnt! 🎉

We're free for open-source projects. if you're enjoying it, help us grow by sharing.

Share on X ·
Reddit ·
LinkedIn

@coderabbitai

coderabbitai Bot commented Jun 27, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@KooshaPari, we couldn't start this review because you've reached your PR review rate limit.

More reviews will be available in 59 minutes and 59 seconds. Learn how PR review limits work.

Your organization has run out of usage credits. Purchase more credits in the billing tab to continue.

⌛ How to resolve this issue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based credits.

🚦 How do rate limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please see our Fair Usage Limits Policy for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro

Run ID: e9e40b16-2f06-47df-a212-8b3bce0480e3

📥 Commits

Reviewing files that changed from the base of the PR and between e589082 and 29cd0d2.

📒 Files selected for processing (2)
  • docs/.vitepress/config.mts
  • docs/.vitepress/resolve-base.mjs
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/asset-base-path

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

Copy link
Copy Markdown

🔍 Legacy Tooling Anti-Pattern Scan

Repository: KooshaPari/AgilePlus
Total Violations: 0

  • 🔴 Critical: 0
  • 🟠 High: 0
  • 🟡 Medium: 0
  • 🔵 Low: 0

✅ No legacy tooling anti-patterns detected!

📄 View Full Report

@github-actions

Copy link
Copy Markdown

Snyk Security Scan Results

Snyk vulnerability scan completed. View results in GitHub Code Scanning dashboard.

@codeant-ai codeant-ai Bot added the size:S This PR changes 10-29 lines, ignoring generated files label Jun 27, 2026
@sonarqubecloud

Copy link
Copy Markdown

@@ -0,0 +1,9 @@
export function resolveDocsBase(repoName) {
const explicit = process.env.DOCS_BASE ?? process.env.VITEPRESS_BASE;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: This resolver drops support for the existing GITHUB_PAGES_BASEURL environment contract, so builds that rely on that variable will silently fall back to repo-name-derived paths and can publish broken asset URLs. Include GITHUB_PAGES_BASEURL in explicit base resolution (with clear precedence) to preserve current CI/runtime behavior. [api mismatch]

Severity Level: Major ⚠️
- ❌ GitHub Pages docs builds ignore configured base URL.
- ⚠️ Env reference for GITHUB_PAGES_BASEURL becomes misleading documentation.
- ⚠️ Future deployments cannot override docs base via env.
Steps of Reproduction ✅
1. Configure a docs build for GitHub Pages using the documented environment snippet at
`docs/reference/env-vars.md:23-35`, setting `GITHUB_PAGES="true"` and
`GITHUB_PAGES_BASEURL="/agileplus"` but not defining `DOCS_BASE` or `VITEPRESS_BASE`.

2. Run the docs build via VitePress using `npm run docs:build` from
`docs/package.json:5-13`, which loads `docs/.vitepress/config.mts:1-9` as the site
configuration.

3. In `docs/.vitepress/config.mts:5-6`, the config derives `repoName` from
`process.env.GITHUB_REPOSITORY` and calls `resolveDocsBase(repoName)` from
`docs/.vitepress/resolve-base.mjs:1-9`, which only checks `DOCS_BASE` and `VITEPRESS_BASE`
for an explicit base (`const explicit = process.env.DOCS_BASE ??
process.env.VITEPRESS_BASE;`) and never reads `GITHUB_PAGES_BASEURL`.

4. Because `GITHUB_PAGES_BASEURL` is ignored, the docs base is computed from `repoName`
and any deployments that relied on setting `GITHUB_PAGES_BASEURL` (per the reference table
at `docs/reference/env-vars.md:31-35`) silently fall back to the repo-name-derived base,
breaking the documented configuration contract and potentially asset paths when a
non-default base URL is configured.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** docs/.vitepress/resolve-base.mjs
**Line:** 2:2
**Comment:**
	*Api Mismatch: This resolver drops support for the existing `GITHUB_PAGES_BASEURL` environment contract, so builds that rely on that variable will silently fall back to repo-name-derived paths and can publish broken asset URLs. Include `GITHUB_PAGES_BASEURL` in explicit base resolution (with clear precedence) to preserve current CI/runtime behavior.

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

return explicit.endsWith('/') ? explicit : `${explicit}/`;
}
if (process.env.PHENOTYPE_CUSTOM_DOMAIN === 'true') return '/';
if (process.env.GITHUB_PAGES === 'true') return `/${repoName}/`;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Suggestion: Always returning /${repoName}/ when GITHUB_PAGES is enabled is incorrect for user/organization Pages repositories (for example <owner>.github.io), which are served from /; this will generate wrong asset paths and 404s. Add a condition to return / for that repository type (or defer to an explicit base variable). [logic error]

Severity Level: Critical 🚨
- ❌ User GitHub Pages docs serve broken asset URLs.
- ❌ Homepage stylesheet requests 404 under root-served site.
- ⚠️ Template cannot safely reuse for user Pages repos.
Steps of Reproduction ✅
1. Create or reuse a GitHub user or organization Pages repository named
`<owner>.github.io` so that the site is served from the root path `/` on
`https://<owner>.github.io/` (standard GitHub Pages behavior for such repos).

2. Build the docs site using `npm run docs:build` from `docs/package.json:5-13` with
`GITHUB_PAGES="true"` set as in the docs snippet at `docs/reference/env-vars.md:23-35`, so
VitePress loads `docs/.vitepress/config.mts:1-9`.

3. In `docs/.vitepress/config.mts:5-6`, the config derives `repoName` from
`process.env.GITHUB_REPOSITORY?.split('/')[1]` (which will be `<owner>.github.io` for this
repo) and passes it to `resolveDocsBase(repoName)`; inside
`docs/.vitepress/resolve-base.mjs:6-8`, the code `if (process.env.GITHUB_PAGES === 'true')
return \`/${repoName}/\`;` computes a base of `/<owner>.github.io/`.

4. `createSiteMeta` in `docs/.vitepress/site-meta.mjs:1-8` receives this base and, with
`PHENOTYPE_CUSTOM_DOMAIN` unset, uses `resolvedBase = base`, causing all navigation links
(e.g., Home at line 13) and VitePress asset URLs to be generated under
`/<owner>.github.io/`; when the site is actually served from `/`, these URLs (such as
`/<owner>.github.io/assets/...`) 404, breaking stylesheets and other static assets for
user/organization GitHub Pages deployments.

Fix in Cursor Fix in VSCode Claude

(Use Cmd/Ctrl + Click for best experience)

Prompt for AI Agent 🤖
This is a comment left during a code review.

**Path:** docs/.vitepress/resolve-base.mjs
**Line:** 7:7
**Comment:**
	*Logic Error: Always returning `/${repoName}/` when `GITHUB_PAGES` is enabled is incorrect for user/organization Pages repositories (for example `<owner>.github.io`), which are served from `/`; this will generate wrong asset paths and 404s. Add a condition to return `/` for that repository type (or defer to an explicit base variable).

Validate the correctness of the flagged issue. If correct, How can I resolve this? If you propose a fix, implement it and please make it concise.
Once fix is implemented, also check other comments on the same PR, and ask user if the user wants to fix the rest of the comments as well. if said yes, then fetch all the comments validate the correctness and implement a minimal fix
👍 | 👎

@codeant-ai

codeant-ai Bot commented Jun 27, 2026

Copy link
Copy Markdown

CodeAnt AI finished reviewing your PR.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 29cd0d22ff

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +7 to +8
if (process.env.GITHUB_PAGES === 'true') return `/${repoName}/`;
return '/';

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Keep the Pages subpath for Actions builds

For the existing Pages workflow that calls the shared deploy job without setting the new GITHUB_PAGES env (.github/workflows/vitepress-deploy.yml only passes concurrency_group), this resolver now falls through to / even though GitHub Actions only guarantees GITHUB_ACTIONS=true. That makes non-custom-domain project Pages builds emit root-relative assets instead of /AgilePlus/..., so the default github.io/AgilePlus deployment will 404 its CSS/JS unless every caller is updated to pass GITHUB_PAGES/DOCS_BASE or this keeps the old Actions fallback when no custom domain is requested.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:S This PR changes 10-29 lines, ignoring generated files

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant