Skip to content

Commit

Permalink
fix: use nodejs runtime instead of edge if running on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
nickreynolds committed Jan 6, 2025
1 parent 7f398ac commit d43a227
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,10 @@ tooling
## Quick Start

> **Note**
> The [db](./packages/db) package is preconfigured to use Supabase and is **edge-bound** with the [Vercel Postgres](https://github.com/vercel/storage/tree/main/packages/postgres) driver. If you're using something else, make the necessary modifications to the [schema](./packages/db/src/schema.ts) as well as the [client](./packages/db/src/index.ts) and the [drizzle config](./packages/db/drizzle.config.ts). If you want to switch to non-edge database driver, remove `export const runtime = "edge";` [from all pages and api routes](https://github.com/t3-oss/create-t3-turbo/issues/634#issuecomment-1730240214).
> The [db](./packages/db) package is preconfigured to use Supabase and is **edge-bound** with the [Vercel Postgres](https://github.com/vercel/storage/tree/main/packages/postgres) driver. If you're using something else, make the necessary modifications to the [schema](./packages/db/src/schema.ts) as well as the [client](./packages/db/src/index.ts) and the [drizzle config](./packages/db/drizzle.config.ts). If you want to switch to non-edge database driver, remove `export const runtime = process.platform === "win32" ? "nodejs" : "edge";` [from all pages and api routes](https://github.com/t3-oss/create-t3-turbo/issues/634#issuecomment-1730240214).
> **Note**
> There is currently a [bug](https://github.com/vercel/next.js/issues/53562) that prevents using the edge runtime when developing a `Next.js` app on Windows with `turborepo`. Because of this bug, we check the platform when exporting the `runtime` variable and default to the `nodejs` runtime if the process is running on Windows.
To get it running, follow the steps below:

Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/auth/[...nextauth]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { NextRequest, NextResponse } from "next/server";

import { handlers, isSecureContext } from "@acme/auth";

export const runtime = "edge";
export const runtime = process.platform === "win32" ? "nodejs" : "edge";

const EXPO_COOKIE_NAME = "__acme-expo-redirect-state";
const AUTH_COOKIE_PATTERN = /authjs\.session-token=([^;]+)/;
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/api/trpc/[trpc]/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { fetchRequestHandler } from "@trpc/server/adapters/fetch";
import { appRouter, createTRPCContext } from "@acme/api";
import { auth } from "@acme/auth";

export const runtime = "edge";
export const runtime = process.platform === "win32" ? "nodejs" : "edge";

/**
* Configure basic CORS headers
Expand Down
2 changes: 1 addition & 1 deletion apps/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
PostList,
} from "./_components/posts";

export const runtime = "edge";
export const runtime = process.platform === "win32" ? "nodejs" : "edge";

export default function HomePage() {
// You can await this here if you don't want to show Suspense fallback below
Expand Down

0 comments on commit d43a227

Please sign in to comment.