Skip to content

Make CORS origins configurable via environment variable in the engine - #152

Open
vikasgoswami2 wants to merge 1 commit into
skyflo-ai:mainfrom
vikasgoswami2:feature/95-engine-cors-origins
Open

Make CORS origins configurable via environment variable in the engine#152
vikasgoswami2 wants to merge 1 commit into
skyflo-ai:mainfrom
vikasgoswami2:feature/95-engine-cors-origins

Conversation

@vikasgoswami2

@vikasgoswami2 vikasgoswami2 commented May 4, 2026

Copy link
Copy Markdown
Contributor

Description

Please include a summary of the changes and the motivation behind them.

Related Issue(s)

#95

Type of Change

  • Feature (new functionality)
  • Bug fix (fixes an issue)
  • Documentation update
  • Code refactor
  • Performance improvement
  • Tests
  • Infrastructure/build changes
  • Other (please describe):

Testing

Please describe the tests you've added/performed to verify your changes.

Checklist

Before Requesting Review

  • I have tested my changes locally
  • My code follows the coding standards
  • I have added/updated necessary documentation
  • I have checked for and resolved any merge conflicts
  • I have linked this PR to relevant issue(s)

Code Quality

  • No debug print statements or console.log calls
  • No package-lock.json (we use yarn only for the UI)
  • No redundant or self-explanatory comments
  • Error handling does not expose internal details to users

Screenshots (if applicable)

Additional Notes

@coderabbitai

coderabbitai Bot commented May 4, 2026

Copy link
Copy Markdown

Review Change Stack

Warning

Rate limit exceeded

@vikasgoswami2 has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 48 minutes and 12 seconds before requesting another review.

You’ve run out of usage credits. Purchase more in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: b7289c45-95ff-4ecc-83a8-b43a3d641c07

📥 Commits

Reviewing files that changed from the base of the PR and between 303eae2 and a89c8e5.

📒 Files selected for processing (6)
  • charts/skyflo/templates/engine-configmap.yaml
  • charts/skyflo/values.yaml
  • deployment/config/engine-configmap.yaml
  • engine/.env.example
  • engine/src/api/config/settings.py
  • engine/src/api/middleware/__init__.py
📝 Walkthrough

Walkthrough

The pull request adds configurable CORS origins support to the Skyflo engine. A new CORS_ORIGINS setting is defined with a default value, exposed through environment configuration files and Helm values, and wired into the FastAPI middleware to dynamically allow specified origins instead of hardcoded localhost entries.

Changes

CORS Configuration & Wiring

Layer / File(s) Summary
Configuration Schema
engine/src/api/config/settings.py
Added CORS_ORIGINS: str field to Settings class with default value "http://localhost:8080,http://127.0.0.1:8080".
Configuration Examples & Templates
engine/.env.example, charts/skyflo/values.yaml, deployment/config/engine-configmap.yaml, charts/skyflo/templates/engine-configmap.yaml
Environment variable documentation, Helm values, and ConfigMap templates updated to expose CORS_ORIGINS configuration and INTEGRATIONS_SECRET_NAMESPACE setting.
Middleware Wiring
engine/src/api/middleware/__init__.py
setup_middleware now imports settings, parses CORS_ORIGINS as a comma-separated trimmed list, and passes the computed origins to CORSMiddleware instead of using hardcoded localhost allowlist.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~8 minutes

Possibly related issues

Poem

🐰 A hop through origins, comma-split and clean,
CORS settings now flourish in every scene,
From localhost bounds to configurations free,
The engine breathes wider, for all to see! 🌟

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: making CORS origins configurable via environment variable in the engine.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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.
Description check ✅ Passed The pull request description is related to the changeset. It mentions linking to issue #95 and indicates testing was performed, which aligns with the CORS origins configurability changes across multiple files.

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

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

Tip

💬 Introducing Slack Agent: The best way for teams to turn conversations into code.

Slack Agent is built on CodeRabbit's deep understanding of your code, so your team can collaborate across the entire SDLC without losing context.

  • Generate code and open pull requests
  • Plan features and break down work
  • Investigate incidents and troubleshoot customer tickets together
  • Automate recurring tasks and respond to alerts with triggers
  • Summarize progress and report instantly

Built for teams:

  • Shared memory across your entire org—no repeating context
  • Per-thread sandboxes to safely plan and execute work
  • Governance built-in—scoped access, auditability, and budget controls

One agent for your entire SDLC. Right inside Slack.

👉 Get started


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

Choose a reason for hiding this comment

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

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/skyflo/templates/engine-configmap.yaml`:
- Line 20: The CORS_ORIGINS env line should use Helm's default filter so an
unset value doesn't render as an empty string and override the Python default;
replace the current use of .Values.engine.config.corsOrigins with the Helm
default form (e.g., default nil .Values.engine.config.corsOrigins) when
rendering the CORS_ORIGINS environment variable (the CORS_ORIGINS key and
.Values.engine.config.corsOrigins reference) so the template either preserves
the app's pydantic default or only injects the env var when a value is provided.

In `@charts/skyflo/values.yaml`:
- Line 42: Uncomment and set a default for the engine.config.corsOrigins value
so the rendered CORS_ORIGINS env var is not an empty string; specifically,
restore/correct the corsOrigins entry in values.yaml to the pydantic-settings
default "http://localhost:8080,http://127.0.0.1:8080" so that the template
interpolation (.Values.engine.config.corsOrigins) used to populate CORS_ORIGINS
in the engine ConfigMap yields a non-empty value and does not override the
Python default to an empty string.

In `@engine/src/api/middleware/__init__.py`:
- Around line 13-16: Check whether cors_origins (computed from
settings.CORS_ORIGINS in the middleware init) is empty before calling
app.add_middleware; if it resolves to an empty list, either log a clear warning
via the application's logger or raise an exception so startup fails fast, and
include the offending settings.CORS_ORIGINS value in the message. Ensure you
update the code path around cors_origins, CORSMiddleware, and app.add_middleware
so operators see a warning/error when no origins are configured.
🪄 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: Organization UI

Review profile: ASSERTIVE

Plan: Pro

Run ID: 482c565a-0c78-4b70-92c7-8c61135f6a2a

📥 Commits

Reviewing files that changed from the base of the PR and between 8104550 and 303eae2.

📒 Files selected for processing (6)
  • charts/skyflo/templates/engine-configmap.yaml
  • charts/skyflo/values.yaml
  • deployment/config/engine-configmap.yaml
  • engine/.env.example
  • engine/src/api/config/settings.py
  • engine/src/api/middleware/__init__.py

Comment thread charts/skyflo/templates/engine-configmap.yaml Outdated
Comment thread charts/skyflo/values.yaml Outdated
Comment thread engine/src/api/middleware/__init__.py
@vikasgoswami2

Copy link
Copy Markdown
Contributor Author

@KaranJagtiani Can you please check and let me know if I need to work on these coderabbit suggestions ?

@KaranJagtiani KaranJagtiani 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.

@vikasgoswami2 please resolve coderabbit comments as well

Comment thread charts/skyflo/values.yaml Outdated
default=None, env="LLM_THINKING_BUDGET_TOKENS"
)
AGENT_TYPE: str = "assistant"
CORS_ORIGINS: str = "http://localhost:8080,http://127.0.0.1:8080"

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.

The default port is wrong. The UI runs on port 3000, not 8080. This breaks local development out of the box. The issue spec explicitly states the default must be http://localhost:3000,http://127.0.0.1:3000 -- that is what was hardcoded before this PR and what the acceptance criteria requires. Port 8080 is nowhere in this codebase as a UI port.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

@KaranJagtiani Are you sure it is running on 3000 port because everywhere for the engine I can see 8080 port. Even in the helm chart engine deployment I can see 8080 port is exposed. It's Dockerfile also expose 8080 port and even though in the ReadMe it is mentioned that engine is running on port 8080. Please find few links where I've seen this :-

Please let me know and based on your response I'll make the necessary changes.

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.

@vikasgoswami2 8080 is the engine port, not the UI origin. CORS controls which browser origins can call the engine, so it must match where the UI is loaded from, not where the engine listens.

The UI runs on 3000 (yarn dev, Next.js containerPort in the UI deployment). In cluster installs the nginx proxy handles /api/v1 on the same origin, so CORS mostly does not matter there. It does matter for local dev when the browser talks to the engine directly, and that origin is localhost:3000.

Please change the default to http://localhost:3000,http://127.0.0.1:3000 across settings, values, and the configmaps.

@vikasgoswami2
vikasgoswami2 force-pushed the feature/95-engine-cors-origins branch 2 times, most recently from 48baa20 to b621ee6 Compare May 11, 2026 12:06
feat (engine): make CORS origins configurable via environment variable
@vikasgoswami2
vikasgoswami2 force-pushed the feature/95-engine-cors-origins branch from b621ee6 to a89c8e5 Compare May 11, 2026 12:16

@KaranJagtiani KaranJagtiani 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.

We can drop the engine scope from the commit msg since it touches deployment files too:

feat: make CORS origins configurable via environment variable

Also, please make the necessary changes wherever the port is incorrect.

default=None, env="LLM_THINKING_BUDGET_TOKENS"
)
AGENT_TYPE: str = "assistant"
CORS_ORIGINS: str = "http://localhost:8080,http://127.0.0.1:8080"

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.

@vikasgoswami2 8080 is the engine port, not the UI origin. CORS controls which browser origins can call the engine, so it must match where the UI is loaded from, not where the engine listens.

The UI runs on 3000 (yarn dev, Next.js containerPort in the UI deployment). In cluster installs the nginx proxy handles /api/v1 on the same origin, so CORS mostly does not matter there. It does matter for local dev when the browser talks to the engine directly, and that origin is localhost:3000.

Please change the default to http://localhost:3000,http://127.0.0.1:3000 across settings, values, and the configmaps.

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.

2 participants