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

Topic summary

A developer is experiencing authentication issues with a Shopify app built using @Shopify/shopify-app-remix and Remix framework. The core problem involves two interconnected issues:

Primary Issue:

  • The shopify_app_session cookie is not being set in browser response headers during authentication
  • This causes re-authentication loops and app loading failures
  • Session data (accessToken, shop name) successfully saves to the database via PrismaSessionStorage, but doesn’t translate to browser cookies

Technical Error:
Persistent TypeScript errors in app/entry.server.tsx when implementing shopify.addDocumentResponseHeaders:

  • Type mismatches between Request and Response objects
  • Missing properties errors (cache, credentials, destination, integrity)
  • Invalid parameter types when passing Headers objects
  • Property existence errors with addDocumentResponseHeaders

Current Status:
Multiple implementation attempts have failed to resolve the TypeScript errors or successfully set the session cookie in the browser’s 200 OK response for the /app route. The issue remains unresolved with no working solution identified.

Summarized with AI on October 26. AI used: claude-sonnet-4-5-20250929.

I am developing a Shopify App using the @Shopify_77 /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.