Repository navigation
Expand file tree
/
Copy pathtanstack-ssr-workers.patch
More file actions
134 lines (131 loc) · 5.49 KB
/
Copy pathtanstack-ssr-workers.patch
File metadata and controls
134 lines (131 loc) · 5.49 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
diff --git a/convex/convex.config.ts b/convex/convex.config.ts
index 1831f4b4fa5703fe1332d9cf45fb2308a57be703..dcc4d5f09735722e1164710651a0c69d58a01869 100644
--- a/convex/convex.config.ts
+++ b/convex/convex.config.ts
@@ -2,7 +2,6 @@ import { defineApp } from "convex/server";
import { v } from "convex/values";
import auth from "@convex-dev/auth/convex.config";
import anonymous from "@convex-dev/auth/components/anonymous/convex.config";
-import hosting from "@samebase/convex-hosting/convex.config";
// A push fails while either variable is missing on the deployment.
const app = defineApp({
@@ -13,5 +12,4 @@ app.use(auth, {
env: { AUTH_PRIVATE_KEY: app.env.AUTH_PRIVATE_KEY, AUTH_JWKS: app.env.AUTH_JWKS },
});
app.use(anonymous);
-app.use(hosting);
export default app;
diff --git a/convex/http.ts b/convex/http.ts
deleted file mode 100644
index 4ae60e6c413b09f9d22481a9cba1b67b633b2529..0000000000000000000000000000000000000000
--- a/convex/http.ts
+++ /dev/null
@@ -1,21 +0,0 @@
-import { httpRouter } from "convex/server";
-import { routeAll } from "@samebase/convex-hosting";
-import { components } from "./_generated/api.js";
-import { assets } from "../.convex-hosting/version.js";
-// Type only, nothing is bundled: the server build imported below.
-import type {} from "@samebase/convex-hosting-tanstack-start/server-build";
-import server from "../dist/server/server.js";
-
-const http = httpRouter();
-
-// Every method, every path: a file for a path that has one (another method than GET or HEAD on it
-// answers 405), the app's server (src/server.ts) for every other path, as a Cloudflare Worker with
-// static assets does.
-const handler = routeAll({ http, component: components.hosting, assets, worker: server });
-// Exact routes for the three auth paths: the Convex Auth component holds the /auth prefix, where it
-// serves the key set, and the longest prefix wins, so the catch-all above never sees them.
-for (const path of ["/auth/signin", "/auth/refresh", "/auth/signout"]) {
- http.route({ path, method: "POST", handler });
-}
-
-export default http;
diff --git a/package.json b/package.json
index 011481b677588aa747f29f9a0945abe4b382e3bd..8eb172e64d333d2718fca213710cf8eabf9b1d0b 100644
--- a/package.json
+++ b/package.json
@@ -1,20 +1,18 @@
{
- "name": "example-tanstack-ssr",
+ "name": "example-tanstack-ssr-workers",
"private": true,
"type": "module",
"scripts": {
- "build": "vp build",
+ "build": "if [ \"$WORKERS_CI\" = 1 ]; then convex deploy --cmd \"vp build\"; else vp build; fi",
"dev": "vp dev",
- "deploy:dev": "convex-hosting deploy --dev --build \"pnpm run build\" --dist dist/client",
- "deploy": "convex-hosting deploy --build \"pnpm run build\" --dist dist/client",
+ "deploy": "wrangler deploy",
+ "deploy:preview": "wrangler preview",
"typecheck": "tsc -p . && tsc -p convex"
},
"dependencies": {
"@convex-dev/auth": "catalog:",
"@convex-dev/react-query": "catalog:",
"@samebase/convex-auth-tanstack-start": "workspace:*",
- "@samebase/convex-hosting": "workspace:*",
- "@samebase/convex-hosting-tanstack-start": "workspace:*",
"@tanstack/react-query": "catalog:",
"@tanstack/react-router": "catalog:",
"@tanstack/react-router-ssr-query": "1.167.3",
@@ -24,10 +22,12 @@
"react-dom": "catalog:"
},
"devDependencies": {
+ "@cloudflare/vite-plugin": "1.63.0",
"@types/react": "catalog:",
"@vitejs/plugin-react": "catalog:",
"typescript": "catalog:",
"vite": "catalog:",
- "vite-plus": "catalog:"
+ "vite-plus": "catalog:",
+ "wrangler": "4.148.0"
}
}
diff --git a/src/server.ts b/src/server.ts
index c4c4df479192d2a3feb175659b9de1420d5a8b8f..a6c3d84c461c20ddc45b4eaeb577c5e92abdad29 100644
--- a/src/server.ts
+++ b/src/server.ts
@@ -1,5 +1,5 @@
import { httpCookies, ServerAuthSession, setupConvexAuthServer } from "@convex-dev/auth/ssr";
-import handler from "@samebase/convex-hosting-tanstack-start/server";
+import handler from "@tanstack/react-start/server-entry";
import { ConvexHttpClient } from "convex/browser";
import { api } from "../convex/_generated/api.js";
diff --git a/vite.config.ts b/vite.config.ts
index 4c87452f03c99b134f721f51abd416b89093f478..4dad8290ce0144e6870fdad55f6733a3a6a98561 100644
--- a/vite.config.ts
+++ b/vite.config.ts
@@ -1,14 +1,14 @@
import { defineConfig } from "vite-plus";
import { tanstackStart } from "@tanstack/react-start/plugin/vite";
import react from "@vitejs/plugin-react";
-import { convexSsr } from "@samebase/convex-hosting-tanstack-start/vite";
+import { cloudflare } from "@cloudflare/vite-plugin";
import { convexAuth } from "@samebase/convex-auth-tanstack-start/vite";
export default defineConfig({
root: import.meta.dirname,
plugins: [
- convexSsr(),
convexAuth(),
+ cloudflare({ viteEnvironment: { name: "ssr" } }),
// Prerenders /about only. `prerender: { enabled: true }` would also prerender every static
// route, and crawling would follow /about's links. The header marks the prerender's requests
// for src/server.ts; a prerender renders without a visitor.
diff --git a/wrangler.jsonc b/wrangler.jsonc
new file mode 100644
index 0000000000000000000000000000000000000000..48c90a9e2b5789638c5baf349fe0cd88dcbbb282
--- /dev/null
+++ b/wrangler.jsonc
@@ -0,0 +1,8 @@
+{
+ "$schema": "node_modules/wrangler/config-schema.json",
+ "compatibility_date": "2026-10-01",
+ "main": "src/server.ts",
+ "preview_urls": true,
+ // `wrangler preview`, the Workers Builds preview command, requires this block.
+ "previews": {},
+}