Skip to content

Add WEBSOCKET_ONLY_MODE to disable REST routes in websocket deployment#3549

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/remove-regular-api-exposure
Draft

Add WEBSOCKET_ONLY_MODE to disable REST routes in websocket deployment#3549
Copilot wants to merge 3 commits intomainfrom
copilot/remove-regular-api-exposure

Conversation

Copy link
Contributor

Copilot AI commented Feb 5, 2026

Websocket deployment (api-ws pods) was loading and exposing all REST API routes despite only serving GraphQL subscriptions, unnecessarily consuming memory and increasing attack surface.

Changes

  • src/types.ts: Added WEBSOCKET_ONLY_MODE environment variable
  • src/index.ts: Wrapped REST route registrations in conditional check
    • Routes skipped when WEBSOCKET_ONLY_MODE=true: /v1/*, /icon, /lettericons, /freyja, /rss/*, /alerts/*, /notifications/*, /webhooks/*, /integrations/*, all other REST routes
    • Always available: /health, /liveness, /graphql with subscriptions
  • .infra/index.ts: Set WEBSOCKET_ONLY_MODE=true for websocket deployment

Example

const isWebsocketOnly = process.env.WEBSOCKET_ONLY_MODE === 'true';

// Skip all REST routes when in websocket-only mode
if (!isWebsocketOnly) {
  app.register(compatibility, { prefix: '/v1' });
  app.register(proxy, { prefix: '/icon' });
  app.register(routes, { prefix: '/' });
}

Other deployments (api, api-bg, api-temporal, api-private) are unaffected.

Original prompt

When running the websocket deployment, I do not want to also expose regular API since it will just consume resources being available


💡 You can make Copilot smarter by setting up custom instructions, customizing its development environment and configuring Model Context Protocol (MCP) servers. Learn more Copilot coding agent tips in the docs.

@CLAassistant
Copy link

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copilot AI and others added 2 commits February 5, 2026 12:35
…ployment

Co-authored-by: omBratteng <1681525+omBratteng@users.noreply.github.com>
Co-authored-by: omBratteng <1681525+omBratteng@users.noreply.github.com>
Copilot AI changed the title [WIP] Remove exposure of regular API during websocket deployment Add WEBSOCKET_ONLY_MODE to disable REST routes in websocket deployment Feb 5, 2026
Copilot AI requested a review from omBratteng February 5, 2026 12:41
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