Skip to content

tanstack/blocks: COOP cannot be unset, and no request-level isBot/deviceOf with deco-runtime semantics #725

Open

Description

@aline-pereira

Summary

Two request-level defaults in @decocms/tanstack / @decocms/blocks (7.80.x) that a Fresh-parity site cannot opt out of, found while porting a VTEX storefront:

1. Cross-Origin-Opener-Policy cannot be disabled

DEFAULT_SECURITY_HEADERS (tanstack/src/sdk/workerEntry.ts) sets Cross-Origin-Opener-Policy: same-origin-allow-popups, and securityHeaders can only override values, not remove a header. deco-cx/Fresh sends no COOP. With the header, a social-login popup (opener → accounts.google.com → back to a storefront page carrying COOP) is moved to a new browsing context group: the opener sees popup.closed === true and reports a failed login although VTEX authenticated the shopper. The site now strips the header from every response in its own fetch wrapper.

Proposal: accept false/null per header in securityHeaders to drop it (or omit COOP by default).

2. No request-level isBot / deviceOf equivalent to deco-runtime's

isBot(userAgent) (blocks/src/cms/resolve.ts) is a substring list tuned for the edge cache ("duckduck", "bing", "google"…), so DuckDuckGo's and Bing's mobile apps are bots; and detectDevice(userAgent) reads only the UA. deco-runtime's utils/userAgent.ts exposes isBot(req) (cf-verified-bot, Google-InspectionTool, ua-parser Bots extension) and deviceOf(req) (?deviceHint= → cf-device-type → ua-parser → desktop). Site code ported from Fresh that branched on them (e.g. an app-store deep-link redirect) changes behaviour: DuckDuckGo/Bing on iPhone/Android got the desktop fallback, and deviceHint was ignored.

Proposal: export request-level isBot(req) / deviceOf(req) with deco-runtime's semantics (e.g. from @decocms/blocks/sdk/userAgent). Site-level port in deco-sites/oficina-tanstack: src/sdk/user-agent.ts (QA-152).

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions