Skip to content

fix (html5/bbb-web): Preloading of slides not working for proxy setups - #25108

Merged
antobinary merged 2 commits into
bigbluebutton:v3.0.x-developfrom
gustavotrott:fetch-slides-proxy
May 20, 2026
Merged

antobinary merged 2 commits into
bigbluebutton:v3.0.x-developfrom
gustavotrott:fetch-slides-proxy

Conversation

@gustavotrott

Copy link
Copy Markdown
Contributor

In proxy setups, slide preloading is currently failing with 401 (Unauthorized) because slides now require authentication to be fetched by nginx.

To fix this in HTML5, we need to include { credentials: 'include' } in the fetch() call.

The second issue is that browsers do not allow credentials to be included when the request is made to a different origin. Because of that, we also need a CORS rule allowing the proxy domain.

I refactored the nginx file so the Access-Control-Allow-Origin value comes from a variable. This allows admins to define the value once and have it applied properly across all locations, instead of having to tweak each location individually.

Looking ahead, we will likely need CORS rules for other locations too, such as shared-notes-server. For that reason, I recommended in the documentation that admins set the CORS domain as an override in /etc/bigbluebutton/nginx/bbb-cluster.nginx. This way, the configuration will not be lost during BBB updates.

By setting the variable there, we can also reuse it in other nginx files. The admin only needs to configure it once, and BBB can take advantage of it wherever needed.

@gustavotrott gustavotrott added this to the Release 3.0 milestone May 19, 2026
@gustavotrott
gustavotrott requested a review from antobinary May 19, 2026 13:21
@coderabbitai

coderabbitai Bot commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

This PR implements credential-aware CORS handling for presentation slide assets. Nginx gains a configurable $bbb_cors_origin variable used for Access-Control-Allow-Origin on presentation asset endpoints (svg, pdf, thumbnails, textfiles) while keeping credentials allowed. The HTML5 PresentationContainer prefetch now uses fetch(..., credentials: 'include') for next-slide SVGs. Documentation adds instructions for setting $bbb_cors_origin in cluster-proxy setups.

Sequence Diagram(s)

sequenceDiagram
  participant Browser
  participant Nginx
  participant BBB_HTML5
  Browser->>Nginx: GET /presentation/... (fetch credentials: 'include')
  Nginx->>BBB_HTML5: proxy_pass request for asset
  BBB_HTML5-->>Nginx: 200 + asset (svg) + CORS headers (Access-Control-Allow-Origin: $bbb_cors_origin)
  Nginx-->>Browser: 200 + asset + Access-Control-Allow-Origin: $bbb_cors_origin + Access-Control-Allow-Credentials: true
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and concisely describes the main change: fixing slide preloading for proxy setups by addressing authentication/CORS issues.
Description check ✅ Passed The description is well-related to the changeset, explaining the problem (401 errors in proxy setups), the solutions (credentials in fetch, CORS configuration), and the rationale for the approach.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (2)
docs/docs/administration/cluster-proxy.md (1)

147-167: ⚠️ Potential issue | 🟡 Minor | ⚡ Quick win

Add a language identifier to the fenced code block.

The block is nginx config; adding the language fixes markdown lint and improves rendering.

📝 Suggested edit
-```
+```nginx
 # Enable per-origin CORS
 # Required because the HTML5 client is served from the proxy origin while slides (and other requests)
 # are fetched directly from this BBB node with credentials
 set $bbb_cors_origin 'https://bbb-proxy.example.com';
 ...
-```
+```
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/docs/administration/cluster-proxy.md` around lines 147 - 167, The fenced
code block containing the nginx configuration (starts with the lines including
"set $bbb_cors_origin 'https://bbb-proxy.example.com';" and the "location
/bbb-01/html5client" blocks) needs a language identifier for proper markdown
linting and rendering — change the opening fence from ``` to ```nginx so the
block is recognized as nginx config.
bigbluebutton-html5/imports/ui/components/presentation/container.jsx (1)

206-217: ⚠️ Potential issue | 🟠 Major | ⚡ Quick win

Use .finally() to restore canFetch on fetch failures.

If any fetch rejects (network/CORS error), Promise.all() rejects and skips the .then() callback, leaving presentation.canFetch = false permanently. This blocks all subsequent preloads since the gate on line 201 requires presentation.canFetch to be true.

Suggested fix
      Promise.all(promiseImageGet)
+       .catch(() => {
+         // Ignore individual preload failures; keep preloading pipeline alive.
+       })
-      .then(() => {
+       .finally(() => {
          presentation.canFetch = true;
-      });
+       });
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@bigbluebutton-html5/imports/ui/components/presentation/container.jsx` around
lines 206 - 217, The current preload flow sets presentation.canFetch = false
before awaiting fetches and only sets it back in Promise.all(...).then(...), so
any rejected fetch leaves presentation.canFetch false; update the Promise.all
call used with promiseImageGet so it uses .finally(...) to restore
presentation.canFetch = true regardless of success or failure (keep the existing
logic where individual successful fetches set
presentation.fetchedSlide[slide.svgUrl] = true inside the mapped async
function), ensuring presentation.canFetch is set to false before starting the
map and always reset in the Promise.all(...).finally(...) callback.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/docs/administration/cluster-proxy.md`:
- Around line 143-145: Fix the typo "raplace" to "replace" and reword the two
bullets for clarity: change the line containing "raplace bbb-proxy.example.com
with your proxy for $bbb_cors_origin" to "replace bbb-proxy.example.com with
your proxy for $bbb_cors_origin", and clarify the second bullet "prepend the
mount point of bbb-html5 in all location sections" to explicitly state which
mount point to prepend (for example "prepend the bbb-html5 mount point (e.g.,
/bbb-html5) to all location paths/blocks in the configuration"). Ensure you
update the exact phrases "raplace bbb-proxy.example.com with your proxy for
$bbb_cors_origin" and "prepend the mount point of bbb-html5 in all location
sections" in the document.

---

Outside diff comments:
In `@bigbluebutton-html5/imports/ui/components/presentation/container.jsx`:
- Around line 206-217: The current preload flow sets presentation.canFetch =
false before awaiting fetches and only sets it back in
Promise.all(...).then(...), so any rejected fetch leaves presentation.canFetch
false; update the Promise.all call used with promiseImageGet so it uses
.finally(...) to restore presentation.canFetch = true regardless of success or
failure (keep the existing logic where individual successful fetches set
presentation.fetchedSlide[slide.svgUrl] = true inside the mapped async
function), ensuring presentation.canFetch is set to false before starting the
map and always reset in the Promise.all(...).finally(...) callback.

In `@docs/docs/administration/cluster-proxy.md`:
- Around line 147-167: The fenced code block containing the nginx configuration
(starts with the lines including "set $bbb_cors_origin
'https://bbb-proxy.example.com';" and the "location /bbb-01/html5client" blocks)
needs a language identifier for proper markdown linting and rendering — change
the opening fence from ``` to ```nginx so the block is recognized as nginx
config.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 1ee39e74-70f8-4ca2-8fea-0a71b61c8f56

📥 Commits

Reviewing files that changed from the base of the PR and between 94a583f and 68e25e0.

📒 Files selected for processing (3)
  • bigbluebutton-html5/imports/ui/components/presentation/container.jsx
  • bigbluebutton-web/nginx-confs/presentation-slides.nginx
  • docs/docs/administration/cluster-proxy.md

@sonarqubecloud

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🧹 Nitpick comments (1)
docs/docs/administration/cluster-proxy.md (1)

147-147: ⚡ Quick win

Consider adding a language specifier to the code fence.

Adding nginx after the opening triple backticks would enable syntax highlighting and satisfy the markdown linter.

✨ Proposed improvement
-```
+```nginx
 # Enable per-origin CORS
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@docs/docs/administration/cluster-proxy.md` at line 147, The Markdown code
fence for the Nginx snippet (the block containing the comment "Enable per-origin
CORS") is missing a language specifier; update the opening triple backticks to
include "nginx" (i.e., change ``` to ```nginx) so the snippet is
syntax-highlighted and the markdown linter is satisfied.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@docs/docs/administration/cluster-proxy.md`:
- Line 147: The Markdown code fence for the Nginx snippet (the block containing
the comment "Enable per-origin CORS") is missing a language specifier; update
the opening triple backticks to include "nginx" (i.e., change ``` to ```nginx)
so the snippet is syntax-highlighted and the markdown linter is satisfied.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 2fe47a40-75f1-4e72-97b1-36d7703585dd

📥 Commits

Reviewing files that changed from the base of the PR and between 68e25e0 and ba11813.

📒 Files selected for processing (1)
  • docs/docs/administration/cluster-proxy.md

@github-actions

Copy link
Copy Markdown

✅ Automated tests have passed!

@defnull

defnull commented May 19, 2026 •

Copy link
Copy Markdown
Contributor

Some suggestions:

bigbluebutton-web/loadbalancer.nginx already exists and defines $bbb_loadbalancer_node. Use that?

if ($bbb_loadbalancer_node != '') {
    set $bbb_cors_origin $bbb_loadbalancer_node;
} else {
    set $bbb_cors_origin '*';
}

Since you are refactoring anyway, maybe add another variable named $bbb_loadbalancer_prefix that is also empty by default, and prepend that to all location rules that would normally need to be changed when using the proxy setup?

@gustavotrott

gustavotrott commented May 19, 2026 •

Copy link
Copy Markdown
Contributor Author

Some suggestions:

bigbluebutton-web/loadbalancer.nginx already exists and defines $bbb_loadbalancer_node. Use that?

if ($bbb_loadbalancer_node != '') {
    set $bbb_cors_origin $bbb_loadbalancer_node;
} else {
    set $bbb_cors_origin '*';
}

Since you are refactoring anyway, maybe add another variable named $bbb_loadbalancer_prefix that is also empty by default, and prepend that to all location rules that would normally need to be changed when using the proxy setup?

I didn't have much experience with cluster setups back when $bbb_loadbalancer_node seemed to be used.

But I checked the references now, and it seems to be obsolete. The last mentions I found were removals:

https://github.com/bigbluebutton/bigbluebutton/pull/21361/changes
264722b

So I'm not sure we should keep relying on it. Are you sure it is still used in production?

Maybe the approach I suggested is safer, since it places the override file under /etc/bigbluebutton/..., which seems to be the current place for override files that should not be replaced by package upgrades.

I don't have a strong opinion here. You are much more familiar with proxy setups than I am, so your opinion is important. I'm just sharing what I found after a brief look into this.

@defnull

defnull commented May 20, 2026 •

Copy link
Copy Markdown
Contributor

You are right, loadbalancer.nginx is not used anywhere and should be removed. I got that confused.

I only have experience deploying a proxy mode cluster using the Ansible role and never tried to do that manually. There are a LOT of changes necessary for proxy mode to work properly, and it's really easy to get wrong. That's probably why so few people actually do that, even though it's way more convenient for users. The role also handles nginx config quite differently.

Okay, let's not over-complicate things. Your PR fixes the issue and I can update the Ansible role to set that variable if proxy mode is enabled. Works for me. We can clean up (an make this easier for admins that do this manually) later.

@gustavotrott

Copy link
Copy Markdown
Contributor Author

You are right, loadbalancer.nginx is not used anywhere and should be removed. I got that confused.

I only have experience deploying a proxy mode cluster using the Ansible role and never tried to do that manually. There are a LOT of changes necessary for proxy mode to work properly, and it's really easy to get wrong. That's probably why so few people actually do that, even though it's way more convenient for users. The role also handles nginx config quite differently.

Okay, let's not over-complicate things. Your PR fixes the issue and I can update the Ansible role to set that variable if proxy mode is enabled. Works for me. We can clean up (an make this easier for admins that do this manually) later.

Sounds like a plan. Thanks a lot for looking into it.

@antobinary antobinary left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

@antobinary
antobinary merged commit 218ceed into bigbluebutton:v3.0.x-develop May 20, 2026
33 checks passed
@antobinary antobinary mentioned this pull request May 29, 2026
16 of 17 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants