-
Notifications
You must be signed in to change notification settings - Fork 143
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@W-14686284@ Fix Preview 403 errors when opening storefront being previewed in a new tab #1629
Conversation
@adamraya we have refresh_token_guest_copy that is stored in local storage, instead of having to keep the refresh_token_guest in both cookies and local. Can we use the
|
@alexvuong I tested that change but it doesn't work well. We have a logic in the storefront that checks whether the SLAS refresh token has changed comparing the values of
Because after setting the context in Preview, the SLAS refresh token always changes, the storefront preview tab refreshes the SLAS token on each soft navigation. This also causes a new message to be sent via postMessage API to Preview, informing that the SLAS token has changed, and it forces to reload to generate a new token in the Storefront Preview tab. We don't have separate browser contexts between the storefront opened in a new tab and the storefront being previewed. |
Description
Problem
When previewing a v3 storefront using Storefront Preview, if the merchant opens the same v3 storefront being previewed in a new browser tab, the storefront opened in the new tab receives 403 error responses for all the SCAPI requests.
This is because the Private SLAS client used in Preview returns a refresh token containing a scope that the Public SLAS client used by the storefront does not have, the SLAS refresh token is configured to be stored in v3 storefronts using cookies. The cookies storage is shared across browser tabs and iframes loading the same domain. Thus both the iframe and the storefront loaded in the new tab use the same SLAS refresh token.
STR:
Workaround
The workaround is to use a different cookie key
cc-nx-g-iframe
andcc-nx-iframe
to store the SLAS refresh token when previewing the storefront. Using different cookie keys separates browser contexts, meaning that different sessions can be active in the browser tabs and the iframe, even if they are loading the same domain.Types of Changes
Changes
How to Test-Drive This PR
Checklists
General
Accessibility Compliance
You must check off all items in one of the follow two lists:
or...
Localization