Cap icon indicating copy to clipboard operation
Cap copied to clipboard

#906 Fix video embedding.

Open dandry opened this issue 1 year ago β€’ 7 comments

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.

dandry avatar Nov 27 '25 15:11 dandry

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.ts to 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 /embed edge case

Adding path.startsWith("/embed/") to the non-CAP allowlist correctly prevents /embed/... from being forced to /login in 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 /login because startsWith("/embed/") won’t match. If such a route exists, you might want to broaden the check (e.g., also permit path === "/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_instructions setting.
  • Format the summary however you like (bullet lists, tables, multi-section layouts, contributor stats, etc.).
  • Use high_level_summary_in_walkthrough to move the summary from the description to the walkthrough section.

Example instruction:

"Divide the high-level summary into five sections:

  1. πŸ“ Description β€” Summarize the main change in 50–60 words, explaining what was done.
  2. πŸ““ References β€” List relevant issues, discussions, documentation, or related PRs.
  3. πŸ“¦ Dependencies & Requirements β€” Mention any new/updated dependencies, environment variable changes, or configuration updates.
  4. πŸ“Š Contributor Summary β€” Include a Markdown table showing contributions: | Contributor | Lines Added | Lines Removed | Files Changed |
  5. βœ”οΈ 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.

❀️ Share

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

coderabbitai[bot] avatar Nov 27 '25 15:11 coderabbitai[bot]

Is there anything I can do to help push this forward?

dandry avatar Dec 29 '25 17:12 dandry

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.

harmonicmean avatar Feb 26 '26 22:02 harmonicmean

+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 avatar Apr 28 '26 14:04 julianwitzel

@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 avatar Apr 29 '26 06:04 dandry

@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 πŸš€

julianwitzel avatar Apr 30 '26 16:04 julianwitzel