SalesforceCommerceCloud / pwa-kit

React-based JavaScript frontend framework to create a progressive web app (PWA) storefront for Salesforce B2C Commerce.
https://developer.salesforce.com/docs/commerce/pwa-kit-managed-runtime/guide/pwa-kit-overview.html
BSD 3-Clause "New" or "Revised" License
285 stars 138 forks source link

@W-17039090@ : [Server Affinity] - Attach dwsid to SCAPI request headers #2090

Closed shethj closed 1 month ago

shethj commented 1 month ago

Description

For a Phased Launch storefront, SCAPI requires each request to contain ECOM dwsid in sfdc_dwsid header with each request. To allow PWA Kit to read dwsid from cookies we require the cookie to be set with httpOnly=false. Plugin SLAS manually sets response cookies and has been setting dwsid with httpOnly=false We can leverage that cookie to be used in PWA Kit to send with each SCAPI request.

Types of Changes

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

How to Test-Drive This PR

Local test run results:

Screenshot 2024-10-22 at 10 00 21 AM

Checklists

General

Accessibility Compliance

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

or...

Localization

vcua-mobify commented 1 month ago

Should we modify the config files in template-retail-react-app and the generator to remove the OCAPI proxy? I think our test mocks set up an OCAPI proxy mock that we'll need to clean up too.

unandyala commented 1 month ago

Should we modify the config files in template-retail-react-app and the generator to remove the OCAPI proxy? I think our test mocks set up an OCAPI proxy mock that we'll need to clean up too.

Is this the only url/api that uses ocapi?

shethj commented 1 month ago

Should we modify the config files in template-retail-react-app and the generator to remove the OCAPI proxy? I think our test mocks set up an OCAPI proxy mock that we'll need to clean up too.

Is this the only url/api that uses ocapi?

Yes. It was the only OCAPI call we were making.

shethj commented 1 month ago

@vcua-mobify @unandyala Great callouts about OCAPI proxy. I tried removing the proxy and ran tests on the deployed store. Looks good to me.

vcua-mobify commented 1 month ago

One more spot we might want to clean up: https://github.com/SalesforceCommerceCloud/pwa-kit/blob/feature/server-affinity-cleanup/packages/pwa-kit-react-sdk/setup-jest.js#L35

vcua-mobify commented 1 month ago

This might be a separate clean up ticket but the generator prompts is for an instanceUrl that, according to a comment in the generator, is only used to set up the OCAPI proxy: https://github.com/SalesforceCommerceCloud/pwa-kit/blob/feature/server-affinity-cleanup/packages/pwa-kit-create-app/scripts/create-mobify-app.js#L801

shethj commented 1 month ago

This might be a separate clean up ticket but the generator prompts is for an instanceUrl that, according to a comment in the generator, is only used to set up the OCAPI proxy: https://github.com/SalesforceCommerceCloud/pwa-kit/blob/feature/server-affinity-cleanup/packages/pwa-kit-create-app/scripts/create-mobify-app.js#L801

Yeah. I'm leaving all generator changes out of this PR. I'll have a follow up ticket for that since it involves testing and changes to tests as well. It'll blow up the scope of this one.