You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the time of writing this tutorial, the `--experimental` flag above uses the `cloudflare` preset (with "Service Worker" syntax) to create the project. This allows the app to be built for, and deployed onto Cloudflare Workers.
Moving to compatibility mode ensures that your application remains forward-compatible with upcoming updates to Nuxt.
68
+
Moving to Nuxt 4 compatibility mode ensures that your application remains forward-compatible with upcoming updates to Nuxt.
73
69
74
70
Create a new `app` folder in the project's root directory and move the `app.vue` file to it. Also, add the following to your `nuxt.config.ts` file:
75
71
@@ -114,10 +110,6 @@ Once the `AI` binding has been configured, run the `cf-typegen` command to gener
114
110
115
111
<PackageManagerstype="run"args="cf-typegen" />
116
112
117
-
:::caution
118
-
Running the `cf-typegen` command might produce an error because the specified entry file (`main = "./dist/worker/index.js"`) does not exist yet. This file will only be created after you build the project. As a temporary workaround, you can comment out this line in `wrangler.toml`, run the `cf-typegen` command, and then uncomment it before building the project.
119
-
:::
120
-
121
113
Create a transcribe `POST` endpoint by creating `transcribe.post.ts` file inside the `/server/api` directory.
122
114
123
115
```ts title="server/api/transcribe.post.ts"
@@ -1161,61 +1153,14 @@ The above code does the following:
1161
1153
1162
1154
## 8. Deploy the application
1163
1155
1164
-
Since the D1 database currently only supports the "Module Worker" syntax, you will need to migrate your existing project from the "Service Worker" format to the ["Module Worker" format](/workers/reference/migrate-to-module-workers/#bindings-in-service-worker-format).
1165
-
1166
-
With `Nitro 2.10.0` (Nitro is the backend that Nuxt uses) this is a straightforward task. Update your `nuxt.config.ts` file and change the nitro preset to `cloudflare_module`.
1167
-
1168
-
```ts title="nuxt.config.ts" del={7} ins={8} {2}
1169
-
exportdefaultdefineNuxtConfig({
1170
-
compatibilityDate: '2024-09-19', // must be this date, or after
1171
-
1172
-
// ...
1173
-
1174
-
nitro: {
1175
-
preset: "./cloudflare-preset"
1176
-
preset: 'cloudflare_module',
1177
-
},
1178
-
1179
-
// ...
1180
-
})
1181
-
```
1182
-
1183
-
Update your `wrangler.toml` file and change the main project entry and assets directory settings. Below is the final `wrangler.toml` file after this change.
Now you are ready to deploy the project to a `.workers.dev` sub-domain by running the deploy command.
1212
1157
1213
1158
<PackageManagerstype="run"args="deploy" />
1214
1159
1215
1160
You can preview your application at `<YOUR_WORKER>.<YOUR_SUBDOMAIN>.workers.dev`.
1216
1161
1217
1162
:::note
1218
-
If you used `pnpm` as your package manager, and may face build errors like `"stdin" is not exported by "node_modules/.pnpm/[email protected]/node_modules/unenv/runtime/node/process/index.mjs"`. To resolve it, you can try hoisting your node modules with the [`shamefully-hoist-true`](https://pnpm.io/npmrc) option.
1163
+
If you used `pnpm` as your package manager, you may face build errors like `"stdin" is not exported by "node_modules/.pnpm/[email protected]/node_modules/unenv/runtime/node/process/index.mjs"`. To resolve it, you can try hoisting your node modules with the [`shamefully-hoist-true`](https://pnpm.io/npmrc) option.
0 commit comments