#906 Fix video embedding.
I believe this change fixes the issue mentioned in #906.
I was not able to verify this, though, as I could not spin up the images I built via GH actions in my forked repository - received an error when I tried to access Cap's dashboard.
Summary by CodeRabbit
Release Notes
- Bug Fixes
- Fixed access control to allow embedded content paths to bypass login redirect in supported environments.
βοΈ Tip: You can customize this high-level summary in your review settings.
Walkthrough
Modified apps/web/middleware.ts to add "/embed/" as a path exception in the access control redirect logic. This permits requests to /embed/... to bypass the login redirect in non-CAP environments, where they previously would have redirected to /login.
Changes
| Cohort / File(s) | Change Summary |
|---|---|
Middleware path exceptions apps/web/middleware.ts |
Added "/embed/" to the allowed path exceptions in access control redirect logic, allowing embedded content requests to bypass login authentication in non-CAP environments. |
Estimated code review effort
π― 1 (Trivial) | β±οΈ ~3 minutes
- Single-file change with minimal scope
- Simple path exception addition to existing logic
- Low risk of unintended side effects; straightforward exception list modification
Possibly related PRs
- CapSoftware/Cap#1332: Also modifies
apps/web/middleware.tsto update access-control allowed-path exceptions, suggesting a related pattern of path-based access control refinement.
Poem
π° A rabbit hops through
/embed/so free, No login gates for thee and me! The middleware bends, exceptions grow, Access flows where admins let it go. β¨
Pre-merge checks and finishing touches
β Failed checks (1 warning)
| Check name | Status | Explanation | Resolution |
|---|---|---|---|
| Docstring Coverage | β οΈ Warning | Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. | You can run @coderabbitai generate docstrings to improve docstring coverage. |
β Passed checks (2 passed)
| Check name | Status | Explanation |
|---|---|---|
| Description Check | β Passed | Check skipped - CodeRabbitβs high-level summary is enabled. |
| Title check | β Passed | The title clearly and specifically relates to the main change: adding /embed/ path exception to middleware, which directly fixes video embedding functionality. The reference to issue #906 provides clear context. |
β¨ Finishing touches
- [ ] π Generate docstrings
π§ͺ Generate unit tests (beta)
- [ ] Create PR with unit tests
- [ ] Post copyable unit tests in a comment
π Recent review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
π₯ Commits
Reviewing files that changed from the base of the PR and between a292974ed15926ca32fc28622d39de347464c3f0 and 66d8979cef59ce297fd805f17268bbb2944a1e7e.
π Files selected for processing (1)
apps/web/middleware.ts(1 hunks)
π Additional comments (1)
apps/web/middleware.ts (1)
40-59: /embed/ allowlist entry matches PR intent; consider bare/embededge caseAdding
path.startsWith("/embed/")to the non-CAP allowlist correctly prevents/embed/...from being forced to/loginin production self-hosted setups and is consistent with the existing/s/behavior.One minor thing to double-check: if any route uses the exact path
/embed(without a trailing slash or segment), it will still be redirected to/loginbecausestartsWith("/embed/")wonβt match. If such a route exists, you might want to broaden the check (e.g., also permitpath === "/embed").
[!TIP]
π Customizable high-level summaries are now available in beta!
You can now customize how CodeRabbit generates the high-level summary in your pull requests β including its content, structure, tone, and formatting.
- Provide your own instructions using the
high_level_summary_instructionssetting.- Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
- Use
high_level_summary_in_walkthroughto move the summary from the description to the walkthrough section.Example instruction:
"Divide the high-level summary into five sections:
- π Description β Summarize the main change in 50β60 words, explaining what was done.
- π References β List relevant issues, discussions, documentation, or related PRs.
- π¦ Dependencies & Requirements β Mention any new/updated dependencies, environment variable changes, or configuration updates.
- π Contributor Summary β Include a Markdown table showing contributions:
| Contributor | Lines Added | Lines Removed | Files Changed |- βοΈ Additional Notes β Add any extra reviewer context. Keep each section concise (under 200 words) and use bullet or numbered lists for clarity."
Note: This feature is currently in beta for Pro-tier users, and pricing will be announced later.
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.
Comment @coderabbitai help to get the list of available commands and usage tips.
Is there anything I can do to help push this forward?
Adding a note that this is a huge blocker for me right now. I'm guessing I speak for @dandry when I say whatever we can do to move this small fix forward, we're happy to do.
Adding my voice. This is a total blocker for me using Cap, and I'd prefer not to fork and hack what looks to be a safe one-liner.
+1, would love to see this merged. Hit this on a fresh self-hosted deploy today (ghcr.io/capsoftware/cap-web:latest). Confirmed the fix is still applicable, just needs to be moved to apps/web/proxy.ts per the recent refactor.
@julianwitzel thank you for your contribution. I've updated my branch. Could you have another test run please?
@richiemcilroy I know you're a busy man, but hopefully we can merge it afterwards π
@dandry confirmed β built from latest main (commit 52b0acc85) with your proxy.ts patch applied at the corresponding location. Embeds now render the player as expected, and direct visits to /embed/<videoId> no longer redirect to /login.
Tested in:
- Logged-out browser (private tab)
- Logged-in browser
- iframe embed on a third-party page
All three work correctly. @richiemcilroy ready for merge from my side π