We're moving the community! Starting July 7, the current community will be read-only for approx. 2 weeks. You can browse content, but posting will be temporarily unavailable. Learn more

Shopify App Remix - Session Cookie Not Set / addDocumentResponseHeaders Type Error in entry.server.t

Shopify App Remix - Session Cookie Not Set / addDocumentResponseHeaders Type Error in entry.server.t

garcode
Shopify Partner
1 0 0

I am developing a Shopify App using the @Shopify/shopify-app-remix library and the Remix framework. I am encountering a critical issue where the shopify_app_session cookie is not being set in the browser's response headers during the authentication flow, preventing my app from loading correctly.

I have followed the setup instructions, including using PrismaSessionStorage for session management. The session data (including accessToken and shop name) is successfully being stored in my database after authentication. However, this session data is not being translated into a browser cookie, leading to re-authentication loops or app loading failures.

The core problem appears to be related to the shopify.addDocumentResponseHeaders function within app/entry.server.tsx and its interaction with Remix's streaming renderToPipeableStream and the Response object. I am consistently getting TypeScript errors when trying to call or use shopify.addDocumentResponseHeaders to set the session cookie.

The specific and recurring TypeScript errors I am encountering in app/entry.server.tsx are:

  • Argument of type 'Response' is not assignable to parameter of type 'Request'. ts(2345) (when attempting to pass a Response object where a Request is expected, or vice-versa, depending on the exact call signature I've tried).

  • Type 'Response' is missing the following properties from type 'Request': cache, credentials, destination, integrity, and X more.

  • Argument of type 'Headers' is not assignable to parameter of type 'Request'. ts(2345) (when attempting to pass a Headers object where a Request is expected).

  • Object literal may only specify known properties, and 'addDocumentResponseHeaders' does not exist in type ... ts(2353) (when attempting to pass shopify.addDocumentResponseHeaders as a direct property to renderToPipeableStream's options).

I have tried multiple variations of implementing shopify.addDocumentResponseHeaders in entry.server.tsx based on various examples and interpretations, but none have successfully resolved the TypeScript errors or resulted in the shopify_app_session cookie being set in the browser's 200 OK response for the /app route.

Replies 0 (0)