Skip to content

Commit

Permalink
feat: adapt the middleware example for cloudflare
Browse files Browse the repository at this point in the history
  • Loading branch information
vicb committed Oct 30, 2024
1 parent 0964f10 commit 3af28ee
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 156 deletions.
4 changes: 4 additions & 0 deletions examples/middleware/next.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
/** @type {import('next').NextConfig} */
const nextConfig = {};

export default nextConfig;
25 changes: 25 additions & 0 deletions examples/middleware/open-next.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import type { OpenNextConfig } from "open-next/types/open-next";

const config: OpenNextConfig = {
default: {
override: {
wrapper: "cloudflare",
converter: "edge",
},
},

middleware: {
external: true,
override: {
wrapper: "cloudflare",
converter: "edge",
},
},

dangerous: {
disableTagCache: true,
disableIncrementalCache: true,
},
};

export default config;
23 changes: 14 additions & 9 deletions examples/middleware/package.json
Original file line number Diff line number Diff line change
@@ -1,22 +1,27 @@
{
"name": "middleware",
"private": true,
"scripts": {
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"build:worker": "pnpm cloudflare",
"dev:worker": "wrangler dev --port 8770 --inspector-port 9330",
"preview:worker": "pnpm build:worker && pnpm dev:worker"
},
"dependencies": {
"next": "latest",
"react": "18.2.0",
"react-dom": "18.2.0"
"next": "catalog:",
"react": "catalog:",
"react-dom": "catalog:"
},
"devDependencies": {
"@opennextjs/cloudflare": "workspace:*",
"@types/node": "18.0.0",
"@types/react": "18.2.8",
"@types/react-dom": "18.0.5",
"eslint": "8.18.0",
"eslint-config-next": "12.2.0",
"typescript": "4.7.4"
"@types/react": "catalog:",
"@types/react-dom": "catalog:",
"eslint": "catalog:",
"typescript": "catalog:",
"wrangler": "catalog:"
}
}
2 changes: 1 addition & 1 deletion examples/middleware/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
]
},
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx", ".next/types/**/*.ts"],
"exclude": ["node_modules"]
"exclude": ["node_modules", "open-next.config.ts"]
}
2 changes: 1 addition & 1 deletion examples/middleware/wrangler.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ compatibility_date = "2024-09-23"
compatibility_flags = ["nodejs_compat"]

# Use the new Workers + Assets to host the static frontend files
assets = { directory = ".open-next/assets", binding = "ASSETS" }
assets = { directory = ".open-next/assets", binding = "ASSETS" }
Loading

0 comments on commit 3af28ee

Please sign in to comment.