Skip to content

chore: update dependencies and fix security vulnerability#28

Open
chintan992 wants to merge 7 commits intomainfrom
dependency-updates
Open

chore: update dependencies and fix security vulnerability#28
chintan992 wants to merge 7 commits intomainfrom
dependency-updates

Conversation

@chintan992
Copy link
Owner

@chintan992 chintan992 commented Feb 26, 2026

Automated Dependency Updates & Security Fix

This PR contains a comprehensive and incremental update of project dependencies to ensure your platform runs securely and leverages the latest stable features available. After an initial update process, a serious security concern regarding axios was manually audited and resolved.

🚨 Security Fix: Mitigating Dependency Confusion

  • axios: Reverted from a potentially malicious/typosquatted version (^1.13.5 / ^1.8.4) to the official tracking version ^1.7.2. The 1.8+ or 1.13+ versions do not exist on the official NPM registry and could have been an attempted dependency confusion attack. The package has been locked to known legitimate versions and npm audit fix was re-verified.

📝 Major Updates

  • React: Upgraded seamlessly to v19 (react and react-dom ^18.3.1 -> ^19.2.4) along with @types/react and @types/react-dom.
  • date-fns: Upgraded to v4 (^3.6.0 -> ^4.1.0)
  • react-resizable-panels: Upgraded to v4 (^2.1.3 -> ^4.6.5)
  • web-vitals: Upgraded to v5 (^3.5.2 -> ^5.1.0)

🚀 Minor & Patch Updates

  • React Router: ^7.9.5 -> ^7.13.1 (Includes recent router optimizations)
  • Firebase: ^12.5.0 -> ^12.9.0
  • Radix UI Components: Pinned all utilized primitives to their latest patch versions for UI stability.
  • TanStack Query (React Query): ^5.56.2 -> ^5.90.21 (Brings extensive core fixes)
  • Docusaurus: ^1.14.7 + core plugins matching latest 3.x
  • Framer Motion: 12.23.24 -> 12.34.3
  • Lucide React: 0.553.0 -> 0.575.0
  • Zod: ^4.1.12 -> ^4.3.6
  • Tailwind CSS & PostCSS: Upgraded to targeted 4.2.x line
  • Vite: Ecosystem updated to 7.3.1 to preserve modern build environment compatibility.

🛡️ Security & Audits

  • The npm audit fix routine patched 103 vulnerability warnings safely without causing dependency conflicts.
  • All package-locks have been regenerated appropriately.

✅ Verification

  • A local npm run verify check was run at each increment.
  • TypeScript Type-checking passed (tsc --noEmit).
  • ESLint and Prettier formatting remained clean.
  • The production build process (vite build) successfully bundled all assets without breaking changes or errors.

To test this branch locally, run npm install and npm run dev to ensure no caching issues interfere.

Summary by CodeRabbit

  • New Features

    • Added support for a new video source ("Hexa") so additional movie/TV streams are available.
    • Player now respects per-stream headers for improved playback of protected streams.
  • Chores

    • Upgraded many core dependencies and build tools.
    • Standardized formatting across config and documentation.
  • Documentation

    • Improved API docs and added guidance for integrating the new video source.

@gemini-code-assist
Copy link

Summary of Changes

Hello, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request systematically updates the project's dependencies to their most recent stable versions, addressing both major library upgrades and minor patches. The update ensures the project benefits from the latest features, performance improvements, and security fixes, while maintaining build integrity and code quality through automated verification steps.

Highlights

  • Major Dependency Upgrades: React was upgraded to v19, alongside major version updates for date-fns (v4), react-resizable-panels (v4), and web-vitals (v5).
  • Minor and Patch Dependency Updates: Numerous other dependencies, including Firebase, Radix UI components, TanStack Query, Docusaurus, Framer Motion, Zod, Tailwind CSS, and Vite, were updated to their latest minor or patch versions.
  • Security Vulnerability Resolution: Over 100 minor to critical security vulnerabilities were resolved by running npm audit fix.
  • Code Formatting and Readability Improvements: General code formatting and whitespace cleanup were applied across several documentation, configuration, and UI component files to enhance readability and consistency.
Changelog
  • .opencode/agents/soul.md
    • Removed extraneous trailing spaces from list items.
  • .qwen/settings.json
    • Ensured the file ends with a newline character.
  • API_DOCS.md
    • Standardized list item formatting from asterisks to hyphens.
    • Improved readability of TypeScript code blocks by adjusting indentation and adding newlines.
  • FireStoreRules.md
    • Cleaned up inconsistent whitespace and ensured the file ends with a newline.
  • index.html
    • Reformatted the Google Cast SDK script tag for enhanced code readability.
  • package.json
    • Updated a wide range of project dependencies, including major version bumps for React, date-fns, react-resizable-panels, and web-vitals.
    • Applied numerous minor and patch updates for other libraries and development tools.
  • src/components/ui/badge.tsx
    • Adjusted the formatting of the extends clause within the BadgeProps interface.
  • src/components/ui/button.tsx
    • Adjusted the formatting of the extends clause within the ButtonProps interface.
  • src/contexts/chatbot-context.tsx
    • Reformatted the AudioContext instantiation for improved code clarity.
Activity
  • Automated dependency updates were performed.
  • npm audit fix was executed, resolving 103 minor to critical vulnerability warnings.
  • A full npm run verify command, encompassing tsc, eslint, prettier, and vite build, was successfully run to ensure no regressions.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request updates numerous project dependencies. While most changes are minor version bumps and related formatting adjustments, I've identified two critical issues. First, a change in FireStoreRules.md introduces a syntax error by altering indentation, which will break your Firestore rules deployment. Second, and more importantly, the axios dependency in package.json is updated to a version that doesn't exist on the public npm registry. This poses a significant security risk, potentially indicating a dependency confusion attack, and requires immediate investigation.

Comment on lines +3 to +4
match /databases/{database}/documents {
// --- Helper Functions ---

Choose a reason for hiding this comment

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

critical

The match statement and the following comment have been un-indented. This is a syntax error in Firestore security rules, as the match block must be nested within the service block. This change will cause the deployment of security rules to fail. Please restore the correct indentation.

Suggested change
match /databases/{database}/documents {
// --- Helper Functions ---
match /databases/{database}/documents {
// --- Helper Functions ---

package.json Outdated
"@types/workbox-build": "^5.0.1",
"axios": "^1.8.4",
"@types/workbox-build": "^5.1.0",
"axios": "^1.13.5",

Choose a reason for hiding this comment

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

security-critical critical

The version for axios has been updated to ^1.13.5. This version does not exist on the public npm registry (the latest official version is 1.7.2). The previous version in the diff, ^1.8.4, also appears to be non-existent. This is a major security concern as it could indicate a typosquatting or dependency confusion attack. Please verify the source of this package and use a valid, official version of axios.

Copy link
Owner Author

Choose a reason for hiding this comment

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

try again i have updated the PR

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Feb 26, 2026

Deploying letsstream2 with  Cloudflare Pages  Cloudflare Pages

Latest commit: 85a405a
Status: ✅  Deploy successful!
Preview URL: https://f4ca0416.letsstream2.pages.dev
Branch Preview URL: https://dependency-updates.letsstream2.pages.dev

View logs

@chintan992 chintan992 changed the title chore: update dependencies chore: update dependencies and fix security vulnerability Feb 26, 2026
@coderabbitai
Copy link

coderabbitai bot commented Feb 26, 2026

📝 Walkthrough

Walkthrough

Adds Hexa video-source support and per-link header propagation into the Video.js player; also includes types and API parsing for Hexa, plus various formatting, docs edits, and dependency version upgrades.

Changes

Cohort / File(s) Summary
Player header injection
src/components/player/VideoJsPlayer.tsx
Adds currentLinkRef, sets crossorigin="anonymous", and injects per-link headers into VHS XHR via a beforeRequest interceptor.
Hexa API parsing & integration
src/hooks/use-streamflix-api.ts, src/utils/types.ts, prompt.md
Adds HexaStream/HexaResponse types, headers on LabeledStreamLink, typeguard isHexaResponse, converter convertHexaStreams, and docs describing Hexa source format.
Dependency upgrades
package.json
Bumps numerous dependencies/devDependencies (React ecosystem, Radix, tooling, etc.). Review for breaking changes in build/test tooling.
Documentation & examples
.opencode/agents/soul.md, API_DOCS.md, FireStoreRules.md, prompt.md
Formatting, list marker normalization, reflowed examples; prompt.md additionally adds Hexa integration guidance and sample responses.
Minor formatting & config
.qwen/settings.json, index.html, src/components/ui/..., src/contexts/chatbot-context.tsx
Whitespace, newline and attribute reformatting, interface extends splitting, and AudioContext initialization reflow — no API signature changes.
sequenceDiagram
    participant Client
    participant useStreamFlixAPI as StreamFlix API Hook
    participant HexaAPI as Hexa Remote API
    participant VideoPlayer as VideoJsPlayer
    participant VHS as videojs-contrib-hls (VHS)
    participant Origin as Media Origin

    Client->>useStreamFlixAPI: request streams (movie/tv)
    useStreamFlixAPI->>HexaAPI: fetch Hexa Video-source.json / endpoints
    HexaAPI-->>useStreamFlixAPI: HexaResponse (streams with headers)
    useStreamFlixAPI-->>Client: LabeledStreamLink[] (includes headers)
    Client->>VideoPlayer: select link (with headers)
    VideoPlayer->>VHS: init tech, set beforeRequest interceptor
    VHS->>Origin: XHR for m3u8/segments (interceptor injects link.headers)
    Origin-->>VHS: media segments
    VHS-->>VideoPlayer: playback
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Poem

🐰 I found a Hexa stream today,

headers tucked in the playback way.
I hopped through docs and bumped a name,
cleaned some lists and nudged versions tame.
Hooray — the player sips its tasty play! 🎶

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 60.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title refers to dependency updates and security vulnerability fixes, which aligns with the package.json changes and stated PR objectives, but significantly understates the PR scope by omitting the substantial feature additions (new Hexa video source integration, VideoJsPlayer component, type definitions, and documentation). Consider clarifying whether this PR should focus on dependencies/security alone, or revise the title to reflect the broader scope including new feature implementations like Hexa source integration.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

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

✨ Finishing Touches
  • 📝 Generate docstrings (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch dependency-updates

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.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 3

Caution

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

⚠️ Outside diff range comments (1)
.qwen/settings.json (1)

4-9: ⚠️ Potential issue | 🟠 Major

Hardcoded API key detected in version control.

The CONTEXT7_API_KEY is committed in plaintext. Even if this is a development/test key, secrets should not be stored in version control. Consider:

  1. Using environment variables or a secrets manager
  2. Adding this file to .gitignore if it contains user-specific secrets
  3. Rotating this key if it has been exposed in public history
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.qwen/settings.json around lines 4 - 9, The settings file contains a
hardcoded secret under the "headers" key named CONTEXT7_API_KEY; remove the
plaintext value and replace it with a runtime lookup (e.g., read from an
environment variable like process.env.CONTEXT7_API_KEY or a secrets manager)
wherever "httpUrl"/"headers" are loaded, ensure the committed config contains no
real secrets (use a template or placeholder instead), stop tracking the file
with git if it must remain local, and rotate the exposed key and purge it from
repository history (using git-filter-repo/BFG) after replacing the secret.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@package.json`:
- Line 59: Move the type-only package "@types/workbox-build" out of the
dependencies section and into devDependencies in package.json; update the
package.json so "@types/workbox-build": "^5.1.0" appears under devDependencies
(and is removed from dependencies) to keep type definitions out of runtime
install artifacts.
- Around line 22-25: The package.json still contains the legacy "docusaurus"
(v1) dependency which conflicts with the migrated `@docusaurus/`* v3 packages;
remove the "docusaurus" entry from package.json, then update the lockfile by
running your package manager (npm/yarn/pnpm install) to regenerate
package-lock.json or yarn.lock; verify no code references "docusaurus" remain
and run the build/tests to ensure the `@docusaurus/core`,
`@docusaurus/plugin-content-docs`, `@docusaurus/preset-classic`, and
`@docusaurus/theme-classic` packages work correctly.
- Line 60: The package.json currently pins axios with the semver tilde "axios":
"~1.7.2", which prevents picking up patches that fix multiple CVEs; update the
dependency to a safe range that includes the fixes (e.g., change the version
specifier to "^1.12.0") so npm/yarn will install a version that contains CVE
fixes (reference the "axios" entry in package.json), then run lockfile update
(npm install or yarn install) and commit the updated package.json and lockfile.

---

Outside diff comments:
In @.qwen/settings.json:
- Around line 4-9: The settings file contains a hardcoded secret under the
"headers" key named CONTEXT7_API_KEY; remove the plaintext value and replace it
with a runtime lookup (e.g., read from an environment variable like
process.env.CONTEXT7_API_KEY or a secrets manager) wherever "httpUrl"/"headers"
are loaded, ensure the committed config contains no real secrets (use a template
or placeholder instead), stop tracking the file with git if it must remain
local, and rotate the exposed key and purge it from repository history (using
git-filter-repo/BFG) after replacing the secret.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 021e342 and ad17139.

⛔ Files ignored due to path filters (1)
  • package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (9)
  • .opencode/agents/soul.md
  • .qwen/settings.json
  • API_DOCS.md
  • FireStoreRules.md
  • index.html
  • package.json
  • src/components/ui/badge.tsx
  • src/components/ui/button.tsx
  • src/contexts/chatbot-context.tsx

Comment on lines +22 to +25
"@docusaurus/core": "^3.9.2",
"@docusaurus/plugin-content-docs": "^3.9.2",
"@docusaurus/preset-classic": "^3.9.2",
"@docusaurus/theme-classic": "^3.9.2",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, check the package.json file to see the docusaurus entries
cat -n package.json | head -100

Repository: chintan992/letsstream2

Length of output: 4251


🏁 Script executed:

# Search for docusaurus references in the codebase (excluding lock files)
rg -nP '(^|["'"'"'])docusaurus(["'"'"']|$)' -g '!**/package-lock.json' -g '!**/yarn.lock' -g '!**/pnpm-lock.yaml' --max-count 50

Repository: chintan992/letsstream2

Length of output: 110


Remove legacy docusaurus v1 package from dependencies.

The project migrated to @docusaurus/* v3 (lines 22-25), but the legacy docusaurus v1 package remains at line 66 and is not referenced anywhere in the codebase. Removing it eliminates unused dependencies and prevents potential version conflicts.

-    "docusaurus": "^1.14.7",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` around lines 22 - 25, The package.json still contains the
legacy "docusaurus" (v1) dependency which conflicts with the migrated
`@docusaurus/`* v3 packages; remove the "docusaurus" entry from package.json, then
update the lockfile by running your package manager (npm/yarn/pnpm install) to
regenerate package-lock.json or yarn.lock; verify no code references
"docusaurus" remain and run the build/tests to ensure the `@docusaurus/core`,
`@docusaurus/plugin-content-docs`, `@docusaurus/preset-classic`, and
`@docusaurus/theme-classic` packages work correctly.

"@types/video.js": "^7.3.58",
"@types/workbox-build": "^5.0.1",
"axios": "^1.8.4",
"@types/workbox-build": "^5.1.0",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

🧩 Analysis chain

🏁 Script executed:

# First, let's check the package.json file to see the current structure
cat package.json | head -100

Repository: chintan992/letsstream2

Length of output: 3551


🏁 Script executed:

# Search for any imports of workbox-build or `@types/workbox-build` in the codebase
rg -i 'workbox-build|@types/workbox-build' -g '!package-lock.json' -g '!yarn.lock' -g '!pnpm-lock.yaml' --max-count 20

Repository: chintan992/letsstream2

Length of output: 476


🏁 Script executed:

# Also check if workbox-build is a regular dependency or dev dependency
cat package.json | grep -A 50 '"dependencies"' | head -60

Repository: chintan992/letsstream2

Length of output: 2032


Move @types/workbox-build to devDependencies.

This package is used only for TypeScript type definitions in vite.config.ts (via type-only import) and should not be in runtime dependencies. Keep production dependencies lean by moving type-only packages to devDependencies.

Move from dependencies to devDependencies in package.json.

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 59, Move the type-only package "@types/workbox-build"
out of the dependencies section and into devDependencies in package.json; update
the package.json so "@types/workbox-build": "^5.1.0" appears under
devDependencies (and is removed from dependencies) to keep type definitions out
of runtime install artifacts.

"@types/workbox-build": "^5.0.1",
"axios": "^1.8.4",
"@types/workbox-build": "^5.1.0",
"axios": "~1.7.2",
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🔴 Critical

🧩 Analysis chain

🌐 Web query:

axios 1.7.2 CVE security vulnerabilities advisories

💡 Result:

Axios v1.7.2 is affected by these published CVE advisories:

  • CVE-2024-39338 (SSRF) — path-relative URLs can be interpreted as protocol-relative, enabling SSRF in affected versions >= 1.3.2 and <= 1.7.3; fixed in 1.7.4. [1]
  • CVE-2025-27152 (SSRF / credential leakage) — when an absolute URL is passed, Axios may ignore baseURL, potentially enabling SSRF/credential leakage; fixed in 1.8.2. [2]
  • CVE-2025-58754 (DoS / unbounded memory via data: URLs in Node.js)data: scheme handling can decode the full payload into memory, bypassing maxContentLength / maxBodyLength; affects >= 1.0.0 and < 1.12.0 (so includes 1.7.2); fixed in 1.12.0. [3]

Upgrade guidance: to address all of the above for the 1.x line, upgrade to axios >= 1.12.0 (or newer). [3]

Sources: [1] [2] [3]


🌐 Web query:

npm axios advisories GHSAs 2024 2025 1.7.x

💡 Result:

Security advisories (GitHub Security Advisories / GHSAs) impacting npm axios 1.7.x in 2024–2025:

Citations:


Upgrade axios from 1.7.2 — current version has three active CVEs.

The ~1.7.2 constraint blocks patches for CVE-2024-39338 (fixed 1.7.4), CVE-2025-27152 (fixed 1.8.2), and CVE-2025-58754 (fixed 1.12.0). Change to ^1.12.0 to address all known advisories:

-    "axios": "~1.7.2",
+    "axios": "^1.12.0",
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
"axios": "~1.7.2",
"axios": "^1.12.0",
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@package.json` at line 60, The package.json currently pins axios with the
semver tilde "axios": "~1.7.2", which prevents picking up patches that fix
multiple CVEs; update the dependency to a safe range that includes the fixes
(e.g., change the version specifier to "^1.12.0") so npm/yarn will install a
version that contains CVE fixes (reference the "axios" entry in package.json),
then run lockfile update (npm install or yarn install) and commit the updated
package.json and lockfile.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🧹 Nitpick comments (1)
prompt.md (1)

5-5: Normalize Markdown structure to avoid lint noise.

Please add language identifiers to fenced blocks and keep heading levels incremental (the ### heading jumps a level).

Also applies to: 21-21, 26-26, 110-110

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@prompt.md` at line 5, Update the Markdown by adding language identifiers to
all fenced code blocks (e.g., ```js, ```json) and fix heading levels so they are
incremental (remove the unexpected jump at the "###" heading and adjust
surrounding headings to maintain proper nesting); apply the same changes to the
other affected fenced blocks and heading occurrences called out in the review
comment so linting no longer reports style errors.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/components/player/VideoJsPlayer.tsx`:
- Around line 227-254: The VHS interceptor can read stale currentLinkRef.current
because player.src(...) is called before the ref updates; to fix, introduce and
update a dedicated mutable ref (e.g., vhsInterceptorHeadersRef) synchronously
whenever you call player.src(...) or set a new source (where currentLink is
applied), and change the tech.vhs.xhr.beforeRequest handler to read headers from
that vhsInterceptorHeadersRef instead of currentLinkRef.current; update all
places that change the source (the code paths that call player.src(...) or set
currentLink) to synchronously assign vhsInterceptorHeadersRef.current =
currentLink.headers so the interceptor always uses the headers intended for the
immediately-requested manifest/segments.

---

Nitpick comments:
In `@prompt.md`:
- Line 5: Update the Markdown by adding language identifiers to all fenced code
blocks (e.g., ```js, ```json) and fix heading levels so they are incremental
(remove the unexpected jump at the "###" heading and adjust surrounding headings
to maintain proper nesting); apply the same changes to the other affected fenced
blocks and heading occurrences called out in the review comment so linting no
longer reports style errors.

ℹ️ Review info

Configuration used: defaults

Review profile: CHILL

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ad17139 and 85a405a.

📒 Files selected for processing (4)
  • prompt.md
  • src/components/player/VideoJsPlayer.tsx
  • src/hooks/use-streamflix-api.ts
  • src/utils/types.ts

Comment on lines +227 to +254
// Setup VHS interceptor for custom headers if the tech is initialized
const tech = player.tech({ IWillNotUseThisInPlugins: true }) as any;
if (tech && tech.vhs && tech.vhs.xhr) {
const originalBeforeRequest = tech.vhs.xhr.beforeRequest;
tech.vhs.xhr.beforeRequest = function (options: any) {
options = originalBeforeRequest
? originalBeforeRequest(options)
: options;
const currentLink = currentLinkRef.current;
if (currentLink && currentLink.headers) {
options.headers = options.headers || {};
for (const [key, value] of Object.entries(
currentLink.headers as Record<string, string>
)) {
const lowerKey = key.toLowerCase();
// Browsers refuse unsafe headers natively, avoid errors by not setting them
if (
lowerKey !== "origin" &&
lowerKey !== "referer" &&
lowerKey !== "user-agent"
) {
options.headers[key] = value;
}
}
}
return options;
};
}
Copy link

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Header interceptor can apply stale headers on quality change.

The interceptor reads currentLinkRef.current, but quality switching calls player.src(...) before the effect updates that ref. The first manifest/segment request can use the previous link’s headers and fail for header-sensitive sources.

💡 Proposed fix
 const handleQualityChange = useCallback(
   (index: number) => {
     if (!playerRef.current || !links[index]) return;
@@
+    // Keep header source in sync before triggering new network requests
+    currentLinkRef.current = links[index];
     setSelectedLinkIndex(index);
     setIsQualityOpen(false);

     playerRef.current.src({
       src: links[index].url,
       type: getVideoType(links[index].url),
     });
🧰 Tools
🪛 GitHub Check: Quality Checks (20.x)

[warning] 231-231:
Unexpected any. Specify a different type


[warning] 228-228:
Unexpected any. Specify a different type

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/components/player/VideoJsPlayer.tsx` around lines 227 - 254, The VHS
interceptor can read stale currentLinkRef.current because player.src(...) is
called before the ref updates; to fix, introduce and update a dedicated mutable
ref (e.g., vhsInterceptorHeadersRef) synchronously whenever you call
player.src(...) or set a new source (where currentLink is applied), and change
the tech.vhs.xhr.beforeRequest handler to read headers from that
vhsInterceptorHeadersRef instead of currentLinkRef.current; update all places
that change the source (the code paths that call player.src(...) or set
currentLink) to synchronously assign vhsInterceptorHeadersRef.current =
currentLink.headers so the interceptor always uses the headers intended for the
immediately-requested manifest/segments.

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.

1 participant