Martial
Martial
Explore posts from servers
NNuxt
Created by Martial on 10/2/2024 in #❓・help
event.waitUntil() or event.context.waitUntil()
Here is the CF doc https://developers.cloudflare.com/workers/runtime-apis/context/ I tried both but none seem to work in local dev server. I couldn't find any answer about it searching on the discord. Do you have an idea ?
4 replies
CDCloudflare Developers
Created by Martial on 10/1/2024 in #pages-help
Bindings depending on the environment
I have some bindings in my wrangler.toml:
[[d1_databases]]
binding = "DB"
database_name = "my-database"
[[d1_databases]]
binding = "DB"
database_name = "my-database"
I would like to specify a different database for the preview env (when deploying on a different branch than main) BUT to keep the same binding. Ideally it would look like these:
[env.preview]
[[env.preview.d1_databases]]
binding = "DB"
database_name = "my-preview-database"
[env.preview]
[[env.preview.d1_databases]]
binding = "DB"
database_name = "my-preview-database"
I have digged in the doc and tried various things. This seems not possible. Of course you can have different binding name but then you have to change your code so it's of no help. Thx in advance for sharing your experience on this.
2 replies
CDCloudflare Developers
Created by Martial on 9/25/2024 in #workers-help
Smart placement issue
I activated smart placement in my wrangler.toml and I have a weird behaviour: every now and then for subsequent deployment, sometimes, the cf-placement header is missing. I have some customer in NZ and D1 instance in west-europe so they instantly notice when it's off as my app gets slow for them. What could cause the fact that the smart placement is deactivated sometimes?
1 replies
NNuxt
Created by Martial on 5/29/2024 in #❓・help
Throwing and catching errors in CF workers
I have an server endpoint in which I throw an error:
throw createError({
statusMessage: "Invalid password",
statusCode: 400,
});
throw createError({
statusMessage: "Invalid password",
statusCode: 400,
});
Now I catch this error in my page with the below code. It works perfectly fine during development. But in production (cloudflare workers), error.statusMessage is undefined. Do you have an idea why ?
try {
await $fetch("/api/login/password/signin", {
method: "POST",
body: formData,
});
} catch (error) {
let message = "Unknown error";
const message = error instanceof FetchError ? error.statusMessage : "Unknown error";
toast.add({title: message});
}
try {
await $fetch("/api/login/password/signin", {
method: "POST",
body: formData,
});
} catch (error) {
let message = "Unknown error";
const message = error instanceof FetchError ? error.statusMessage : "Unknown error";
toast.add({title: message});
}
2 replies
NNuxt
Created by Martial on 5/14/2024 in #❓・help
How can I prevent VSCode from adding the import statement for auto-imported components?
No description
7 replies