@W-19869537 Added Hybrid Proxy support for local and ODS hybrid development when no eCDN available#3409
@W-19869537 Added Hybrid Proxy support for local and ODS hybrid development when no eCDN available#3409
Conversation
- 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 <126732792+aditek-sf@users.noreply.github.com>
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
| 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]) | ||
| }) | ||
| } |
There was a problem hiding this comment.
These appear to be generic util functions. Do they need to be a part of hybridProxy.js ?
There was a problem hiding this comment.
I will move them to utils.js. Thanks!
| 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', |
There was a problem hiding this comment.
Did we consider reading this from config/env instead of hard-coding the hostname ?
There was a problem hiding this comment.
This can be read from env var but the ask from one pager is to leave the decision to use env var to the customer that's why the string is used here.
| // * 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+)"' |
There was a problem hiding this comment.
Same here. Can we avoid hard-coding the routing rules and make them configurable via env var ?
There was a problem hiding this comment.
It can be read from env var but according to one pager we would like to leave the decision to customer and not introduce dotenv dependency in the project.
Customers can always implement using in env-vars on their own; our documenting using plain config will be simpler without introducing that extra dependency (and no need for the 3PP). Furthermore the rule set is unlikely to change within a customers implementation and they will likely only use env-vars for the ECOM upstream. We will leave this up to them.
| // 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, |
There was a problem hiding this comment.
Thank you for catching this. I will update it.
There was a problem hiding this comment.
ssr.js.hbs is updated for both extensible and non-extensible and tested in generated project for:
- my own instance
-- non extensible
-- extensible - demo instance
|
I see the steps to test require updates to config/default.js: I don't see corresponding code changes to Also for the config consider naming: |
Yeah I understood the changes. I was wondering if the config.js changes should be shipped with defaults OOTB. |
@shethj You are right but the main problem is client might configure |
| enabled: false, | ||
|
|
||
| // The origin of the SFCC instance (i.e. the instance that is being proxied to which hosts the storefront). | ||
| sfccOrigin: 'https://{{answers.project.commerce.instanceUrl}}', |
There was a problem hiding this comment.
use {{answers.project.commerce.instanceUrl}} so that user does not need to update this manually in ssr.js
| enabled: false, | ||
|
|
||
| // The origin of the SFCC instance (i.e. the instance that is being proxied to which hosts the storefront). | ||
| sfccOrigin: 'https://{{answers.project.commerce.instanceUrl}}', |
There was a problem hiding this comment.
use {{answers.project.commerce.instanceUrl}} so that user does not need to update this manually in ssr.js
| @@ -0,0 +1,150 @@ | |||
| /* | |||
There was a problem hiding this comment.
@yhsieh1 Can we please rename this file to hybrid-proxy.js to make sure we follow the naming convention to match other files in the package. Also for the test file.
Thanks!
There was a problem hiding this comment.
Thank you for catching this. I did not notice the file name is not right.
Signed-off-by: yhsieh1 <yhsieh@salesforce.com>
|
LGTM 👍 |
| @@ -3,6 +3,7 @@ | |||
| - Prompt text for Site ID should match actual validation: Site ID may contain uppercase or lowercase letters, numbers, hyphens, or underscores. - Updated Site ID validator regex to allow both uppercase and lowercase letters for improved compatibility, clarity. [#3410] (https://github.com/SalesforceCommerceCloud/pwa-kit/pull/3410) | |||
|
|
|||
| ## v3.14.0-dev (Sep 26, 2025) | |||
There was a problem hiding this comment.
maybe not this PR directly, but why are there two v3.14.0-dev sections?
There was a problem hiding this comment.
Thanks @patricksullivansf. It must be the auto merge. I fixed it.
c0e0e18
Signed-off-by: yhsieh1 <yhsieh@salesforce.com>

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
A pwa-kit storefront with hybrid proxy enabled is deployed on MRT and connected to ODS for testing.
Types of Changes
Changes
How to Test-Drive This PR
Steps to test:
Uncomment hybridAuthEnabled in _app-config.js
Update routes.jsx to exclude routes on the PWA-Kit. Reference this code
Update default.js
{
host: [your SFCC store],
path: 'dwrestatic'
}
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization