Skip to content

Conversation

@field123
Copy link
Collaborator

@field123 field123 commented Jan 30, 2026

Summary

  • Add restricted CORS middleware for Commerce Manager origins
  • Support for all environments
  • Support for localhost:3000 (development)
  • Support for Vercel preview deployments ({MR}--{env}-commerce-manager.vercel.app)

Endpoints Updated

  • /api/v1/auth/self, /api/v1/auth/csrf
  • /api/v1/app-config
  • /api/v1/projects (list, create, clone, update, delete, meta, update-host)
  • /api/v1/cmse/databases (list, create, clone, delete)

Files Changed

  • platform/wab/src/wab/server/cm-cors.ts (new)
  • platform/wab/src/wab/server/AppServer.ts

Add restricted CORS middleware for CM origins:
- integration/staging/useast/euwest.cm.elasticpath.com
- localhost:3000
- Vercel preview deployments ({MR}--{env}-commerce-manager.vercel.app)

Endpoints updated:
- /api/v1/auth/self, /api/v1/auth/csrf
- /api/v1/app-config
- /api/v1/projects (list, create, clone, update, delete, meta, update-host)
- /api/v1/cmse/databases (list, create, clone, delete)
Replace hardcoded environment URLs with regex pattern for
*.cm.elasticpath.com to avoid exposing internal environment
names in public code.
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adds restricted CORS middleware to enable cross-origin requests from Commerce Manager frontends to specific API endpoints. The implementation creates a new module with origin validation that allows requests from elasticpath.com subdomains, Vercel preview deployments, and localhost:3000.

Changes:

  • New CORS middleware module (cm-cors.ts) with origin validation for Commerce Manager domains
  • Applied CORS middleware to authentication, app-config, projects, and CMS database endpoints
  • Added preflight OPTIONS handlers for all Commerce Manager-accessible routes

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 10 comments.

File Description
platform/wab/src/wab/server/cm-cors.ts New CORS middleware with origin validation for Commerce Manager domains (elasticpath.com, Vercel previews, localhost)
platform/wab/src/wab/server/AppServer.ts Applied cmCors middleware to auth, projects, and CMS endpoints; added cmCorsPreflight OPTIONS handlers

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

- Use stricter regex [a-zA-Z0-9-] instead of \w (no underscores)
- Add logging for rejected origins
- Use callback(null, false) instead of Error for CORS rejection
- Add cmCors to missing cmse database endpoints
- Add test coverage for isCmOriginAllowed function
@field123 field123 merged commit b616b00 into master Jan 30, 2026
14 of 15 checks passed
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