Skip to content

fix: add cors headers#6733

Merged
tanflem merged 3 commits into
mainfrom
tannerfleming/prj-2766-cors-issue-on-dl
May 22, 2025
Merged

fix: add cors headers#6733
tanflem merged 3 commits into
mainfrom
tannerfleming/prj-2766-cors-issue-on-dl

Conversation

@tanflem
Copy link
Copy Markdown
Contributor

@tanflem tanflem commented May 22, 2025

Summary by CodeRabbit

  • Chores
    • Improved consistency of CORS headers across all routes, ensuring cross-origin requests are handled uniformly.
    • Renamed the download option to "low quality" and simplified quality selection for downloads.

@linear
Copy link
Copy Markdown

linear Bot commented May 22, 2025

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented May 22, 2025

"""

Walkthrough

A new helper function, setCorsHeaders, was introduced to centralize the setting of CORS headers in the route handlers. All relevant routes and the OPTIONS handler now use this function to apply CORS headers uniformly. The route downloadRoute was renamed to lowQualityRoute and simplified to always serve low quality. Inline CORS header settings were removed in favor of this centralized approach, with no other logic changes.

Changes

File(s) Change Summary
apps/arclight/src/app/[...route]/route.ts Added setCorsHeaders helper; renamed downloadRoute to lowQualityRoute and simplified its logic; updated all relevant route handlers and OPTIONS handler to use setCorsHeaders; removed inline CORS header settings from handlers.

Sequence Diagram(s)

sequenceDiagram
    participant Client
    participant RouteHandler
    participant setCorsHeaders

    Client->>RouteHandler: Send request (any supported route)
    RouteHandler->>setCorsHeaders: Apply CORS headers to response
    setCorsHeaders-->>RouteHandler: Headers set
    RouteHandler-->>Client: Respond with CORS headers included
Loading

Possibly related PRs

  • feat: possible fix for cors issues #6581: Modifies CORS handling in the same file by adding a global OPTIONS handler and changing /hls route behavior, similar in scope to the centralization of CORS logic in this PR.
    """

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 ESLint

If the error stems from missing dependencies, add them to the package.json file. For unrecoverable errors (e.g., due to private dependencies), disable the tool in the CodeRabbit configuration.

npm warn config production Use --omit=dev instead.
npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: 'i18next-parser@9.3.0',
npm warn EBADENGINE required: { node: '^18.0.0 || ^20.0.0 || ^22.0.0', npm: '>=6', yarn: '>=1' },
npm warn EBADENGINE current: { node: 'v24.0.2', npm: '11.3.0' }
npm warn EBADENGINE }
npm warn EBADENGINE Unsupported engine {
npm warn EBADENGINE package: 'next-firebase-auth-edge@1.9.1',
npm warn EBADENGINE required: {
npm warn EBADENGINE node: '>=16.0.0 <24.0.0',
npm warn EBADENGINE npm: '>=8.0.0 <12.0.0',
npm warn EBADENGINE yarn: '>=1.22.0 <2.0.0'
npm warn EBADENGINE },
npm warn EBADENGINE current: { node: 'v24.0.2', npm: '11.3.0' }
npm warn EBADENGINE }
npm error Exit handler never called!
npm error This is an error with npm itself. Please report this error at:
npm error https://github.com/npm/cli/issues
npm error A complete log of this run can be found in: /.npm/_logs/2025-05-22T03_30_31_466Z-debug-0.log


📜 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 de8a7e9 and 04c468d.

📒 Files selected for processing (1)
  • apps/arclight/src/app/[...route]/route.ts (8 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • apps/arclight/src/app/[...route]/route.ts
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Deploy Preview and Test (arclight, 6733/merge, pull_request, 22)
  • GitHub Check: Analyze (javascript)
✨ Finishing Touches
  • 📝 Generate Docstrings

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

@tanflem tanflem requested a review from mikeallisonJS May 22, 2025 01:17
@tanflem tanflem self-assigned this May 22, 2025
@github-actions github-actions Bot temporarily deployed to Preview - arclight May 22, 2025 01:17 Inactive
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 22, 2025

The latest updates on your projects.

Name Status Preview Updated (UTC)
arclight ✅ Ready arclight preview Thu May 22 15:31:21 NZST 2025

Copy link
Copy Markdown
Contributor

@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 (2)
apps/arclight/src/app/[...route]/route.ts (2)

69-74: Use a strongly‐typed context and leverage Hono’s built-in CORS
The helper is currently declared as c: any, which erases type safety. Import and use Hono’s Context type (e.g. import type { Context } from 'hono') for c. Moreover, you can replace this custom function entirely by using Hono’s native middleware:

import { cors } from 'hono/cors'
app.use(cors({ origin: '*' }))

This applies CORS headers globally, handles wildcard headers more robustly, and avoids manual header management.


294-295: Centralize CORS injection instead of per-route calls
Every route handler begins with setCorsHeaders(c), which is repetitive and error-prone. By applying a global middleware (app.use(cors(...))) or registering a single pre-handler for your OpenAPI routes, you eliminate boilerplate and ensure no route is left out.

Also applies to: 325-326, 352-353, 375-376, 388-389

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 187ad64 and 09b1b6f.

📒 Files selected for processing (1)
  • apps/arclight/src/app/[...route]/route.ts (7 hunks)
⏰ Context from checks skipped due to timeout of 90000ms (2)
  • GitHub Check: Deploy Preview and Test (arclight, 6733/merge, pull_request, 22)
  • GitHub Check: Analyze (javascript)

Comment thread apps/arclight/src/app/[...route]/route.ts
@github-actions github-actions Bot temporarily deployed to Preview - arclight May 22, 2025 01:25 Inactive
@stage-branch-merger
Copy link
Copy Markdown
Contributor

I see you added the "on stage" label, I'll get this merged to the stage branch!

@stage-branch-merger
Copy link
Copy Markdown
Contributor

Merge conflict attempting to merge this into stage. Please fix manually.

@tanflem tanflem added on stage and removed on stage labels May 22, 2025
@stage-branch-merger
Copy link
Copy Markdown
Contributor

I see you added the "on stage" label, I'll get this merged to the stage branch!

@github-actions github-actions Bot temporarily deployed to Preview - arclight May 22, 2025 03:29 Inactive
@tanflem tanflem added this pull request to the merge queue May 22, 2025
Merged via the queue into main with commit 4e0b8f7 May 22, 2025
21 checks passed
@tanflem tanflem deleted the tannerfleming/prj-2766-cors-issue-on-dl branch May 22, 2025 19:01
mikeallisonJS pushed a commit that referenced this pull request May 22, 2025
@coderabbitai coderabbitai Bot mentioned this pull request Jun 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants