Skip to content

Accessing context and env during entry.server.tsx #1338

Answered by juanpprieto
magnattic asked this question in Help
Discussion options

You must be logged in to vote

👋🏼 @magnattic

You can access the server.ts context via the handleRequest loadContext property

// entry.server.ts
import type {EntryContext, AppLoadContext} from '@shopify/remix-oxygen';
import {RemixServer} from '@remix-run/react';
import isbot from 'isbot';
import {renderToReadableStream} from 'react-dom/server';

export default async function handleRequest(
  request: Request,
  responseStatusCode: number,
  responseHeaders: Headers,
  remixContext: EntryContext,
  loadContext: AppLoadContext,
) {
  console.log('loadContext === server.ts context', loadContext);
  // ... other code
}

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@magnattic
Comment options

@juanpprieto
Comment options

Answer selected by magnattic
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet
2 participants