Skip to content

Conversation

yhsieh1
Copy link
Contributor

@yhsieh1 yhsieh1 commented Oct 20, 2025

Description

Overview
This PR introduces Hybrid Proxy support for PWA Kit, enabling seamless integration between PWA Kit applications and Salesforce Commerce Cloud (SFCC) instances during local development and ODS hybrid scenarios when no eCDN is available.

🎯 Key Changes

  1. Added Hybrid Proxy in pwa-kit-runtime
  2. Added Hybrid Proxy Configuration in template-retail-react-app app/ssr.js
  3. Extra unit test is added to improve and pass test coverage requirement

A pwa-kit storefront with hybrid proxy enabled is deployed on MRT and connected to ODS for testing.

Screenshot 2025-10-20 at 10 32 13 AM

Types of Changes

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Documentation update
  • Breaking change (could cause existing functionality to not work as expected)
  • Other changes (non-breaking changes that does not fit any of the above)

Breaking changes include:

  • Removing a public function or component or prop
  • Adding a required argument to a function
  • Changing the data type of a function parameter or return value
  • Adding a new peer dependency to package.json

Changes

  • Added Hybrid Proxy support for local and ODS hybrid development when no eCDN available

How to Test-Drive This PR

Steps to test:

  1. Update ssr.js to enable Hybrid Proxy
  • localAllowCookies: true
  • hybridProxy.enabled: true
  • hybridProxy.sfccOrigin: [your SFCC store]
  1. Uncomment hybridAuthEnabled in _app-config.js

  2. Update routes.jsx to exclude routes on the PWA-Kit. Reference this code

  3. Update default.js

  • app.commerceAPI.parameters
  • app.enableHybrid: true to toggle routes exclusion on routes.jsx
  • ssrParameters.proxyConfigs: add
    {
    host: [your SFCC store],
    path: 'dwrestatic'
    }
  1. Start up app
  • Add item to cart
  • Go to cart
  • It should show SFCC store cart page

Checklists

General

  • Changes are covered by test cases
  • CHANGELOG.md updated with a short description of changes (not required for documentation updates)

Accessibility Compliance

You must check off all items in one of the follow two lists:

  • There are no changes to UI

or...

Localization

  • Changes include a UI text update in the Retail React App (which requires translation)

yhsieh1 and others added 6 commits October 8, 2025 12:08
- Resolved merge conflicts in pwa-kit-mcp package
- Added new tools: hooks-recommendation and explore-scapi-shop-api
- Updated CHANGELOG.md and README.md with new features
- Merged changes from develop branch including new MCP tools and utilities
* Hybrid CDN 1st pass

---------

Signed-off-by: Aditya Tekur <[email protected]>
@yhsieh1 yhsieh1 requested a review from a team as a code owner October 20, 2025 14:11
@cc-prodsec
Copy link
Collaborator

cc-prodsec commented Oct 20, 2025

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Licenses 0 0 0 0 0 issues
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Comment on lines +131 to +140
const isString = (element) => typeof element === 'string'
const isArray = (element) => Array.isArray(element)
const isObject = (element) => element && typeof element === 'object'
const isIterable = (element) => isArray(element) || isObject(element)

const forEachIn = (iterable, functionRef) => {
Object.keys(iterable).forEach((key) => {
functionRef(key, iterable[key])
})
}
Copy link
Contributor

Choose a reason for hiding this comment

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

These appear to be generic util functions. Do they need to be a part of hybridProxy.js ?

enabled: false,

// The origin of the SFCC instance (i.e. the instance that is being proxied to which hosts the storefront).
sfccOrigin: 'https://zzrf-001.dx.commercecloud.salesforce.com',
Copy link
Contributor

@shethj shethj Oct 21, 2025

Choose a reason for hiding this comment

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

Did we consider reading this from config/env instead of hard-coding the hostname ?

// * https://developer.salesforce.com/docs/commerce/commerce-api/references/cdn-api-process-apis?meta=MrtRules
// * https://developer.salesforce.com/docs/commerce/commerce-api/guide/ecdn-rules-for-phased-headless-rollout.html
routingRules: [
'http.request.uri.path eq "/" or http.request.uri.path matches "^/callback" or http.request.uri.path matches "^/mobify" or http.request.uri.path matches "^/worker.js" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/$" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/login" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/reset-password" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/registration" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/account" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/account/orders" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/account/orders/(\\\\w+)" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/account/wishlist" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/product/(\\\\w+)" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/search" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/category/(\\\\w+)" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/order-status" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/page/(\\\\w+)" or http.request.uri.path matches "^/(\\\\w+)/([-\\\\w]+)/page-viewer/(\\\\w+)"'
Copy link
Contributor

@shethj shethj Oct 21, 2025

Choose a reason for hiding this comment

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

Same here. Can we avoid hard-coding the routing rules and make them configurable via env var ?

// HYBRID PROXY REQUIREMENT:
// - Hybrid Proxy requires this to be 'true' for SFCC session management to work properly
// - Only enable Hybrid Proxy in development environments, never in production
localAllowCookies: false,
Copy link
Contributor

Choose a reason for hiding this comment

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

I don't see these options in the generated app. You might need to update the handlebar files. Please make sure you test the code with generated apps as well (with and without extensibility.)

Image

@shethj
Copy link
Contributor

shethj commented Oct 21, 2025

I see the steps to test require updates to config/default.js:

app.commerceAPI.parameters
app.enableHybrid: true to toggle routes exclusion on routes.jsx
ssrParameters.proxyConfigs: add
{
host: [your SFCC store],
path: 'dwrestatic'
}

I don't see corresponding code changes to config/default.js in the PR.
Is this expected ?

Also for the config consider naming: app.enableHybridProxy: true because app.enableHybrid: true comes across as something I should enable for hybrid in general.

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.

4 participants