create-surf-app 1.0.0-alpha.11 → 1.0.0-alpha.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -5,7 +5,7 @@
5
5
  "dev": "node scripts/check-env.js node --watch server.js"
6
6
  },
7
7
  "dependencies": {
8
- "@surf-ai/sdk": "1.0.0-alpha.11",
8
+ "@surf-ai/sdk": "1.0.0-alpha.13",
9
9
  "express": "4.22.1"
10
10
  }
11
11
  }
@@ -15,6 +15,21 @@ function useSurfAppReady() {
15
15
  }, [])
16
16
  }
17
17
 
18
+ // Patch fetch so `/api/*` calls automatically include basePath.
19
+ // Without this, `fetch('/api/...')` hits the parent app's routes instead of
20
+ // the preview dev server's API routes.
21
+ // DO NOT REMOVE — this is required for the preview proxy architecture.
22
+ const _basePath = process.env.NEXT_PUBLIC_BASE_PATH || ""
23
+ if (typeof window !== "undefined" && _basePath) {
24
+ const _origFetch = window.fetch
25
+ window.fetch = function patchedFetch(input, init) {
26
+ if (typeof input === "string" && input.startsWith("/api/")) {
27
+ input = _basePath + input
28
+ }
29
+ return _origFetch.call(this, input, init)
30
+ } as typeof window.fetch
31
+ }
32
+
18
33
  export function Providers({ children }: { children: React.ReactNode }) {
19
34
  useSurfAppReady()
20
35
 
@@ -3,6 +3,9 @@ import type { NextConfig } from 'next'
3
3
  const nextConfig: NextConfig = {
4
4
  output: 'standalone',
5
5
  basePath: process.env.BASE_PATH!.replace(/\/+$/, ''),
6
+ env: {
7
+ NEXT_PUBLIC_BASE_PATH: process.env.BASE_PATH!.replace(/\/+$/, ''),
8
+ },
6
9
  serverExternalPackages: ['@surf-ai/sdk', 'drizzle-orm', 'drizzle-kit', 'croner'],
7
10
  logging: {
8
11
  browserToTerminal: true,
@@ -8,7 +8,7 @@
8
8
  "type-check": "tsc --noEmit --incremental"
9
9
  },
10
10
  "dependencies": {
11
- "@surf-ai/sdk": "1.0.0-alpha.11",
11
+ "@surf-ai/sdk": "1.0.0-alpha.13",
12
12
  "@surf-ai/theme": "latest",
13
13
  "next": "15.5.14",
14
14
  "react": "19.2.4",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-surf-app",
3
- "version": "1.0.0-alpha.11",
3
+ "version": "1.0.0-alpha.13",
4
4
  "description": "Scaffold a Surf app — Vite + React + Express + @surf-ai/sdk",
5
5
  "type": "module",
6
6
  "bin": {
@@ -1,11 +0,0 @@
1
- {
2
- "name": "surf-app",
3
- "private": true,
4
- "workspaces": ["backend", "frontend"],
5
- "scripts": {
6
- "dev": "concurrently \"npm run dev --workspace backend\" \"npm run dev --workspace frontend\""
7
- },
8
- "devDependencies": {
9
- "concurrently": "^9.0.0"
10
- }
11
- }