fasm
fasm
Explore posts from servers
CDCloudflare Developers
Created by fasm on 1/24/2024 in #general-help
KV API giving FormData errors
I'm trying to write to KV, following the API docs here: https://developers.cloudflare.com/api/operations/workers-kv-namespace-write-key-value-pair-with-metadata However I continue to get this response
{
result: null,
success: false,
errors: [
{
code: 10047,
message: "can not parse value and metadata from multipart request body: 'error getting part of multipart request, after reading 0 parts: 'multipart: NextPart: EOF''"
}
],
messages: []
}
{
result: null,
success: false,
errors: [
{
code: 10047,
message: "can not parse value and metadata from multipart request body: 'error getting part of multipart request, after reading 0 parts: 'multipart: NextPart: EOF''"
}
],
messages: []
}
Here's my code with some hardcoded values for testing:
export async function kvSet(key: string, value: any, opts: { metadata?: Record<string, string> }) {
const form = new FormData();
form.append("metadata", "");
form.append("value", "test");


const options = {
method: 'PUT',
headers: {
'Content-Type': 'multipart/form-data; boundary=---011000010111000001101001',
Authorization: `Bearer ${env.KV_AUTH_TOKEN}`
},
};
options.body = form
console.log(options)



const response = await fetch(`https://api.cloudflare.com/client/v4/accounts/${env.KV_ACCOUNT_ID}/storage/kv/namespaces/${env.KV_NAMESPACE_ID}/values/${key}`, options)
const result = await response.json()
console.log("set result", result)
return result.result

}
export async function kvSet(key: string, value: any, opts: { metadata?: Record<string, string> }) {
const form = new FormData();
form.append("metadata", "");
form.append("value", "test");


const options = {
method: 'PUT',
headers: {
'Content-Type': 'multipart/form-data; boundary=---011000010111000001101001',
Authorization: `Bearer ${env.KV_AUTH_TOKEN}`
},
};
options.body = form
console.log(options)



const response = await fetch(`https://api.cloudflare.com/client/v4/accounts/${env.KV_ACCOUNT_ID}/storage/kv/namespaces/${env.KV_NAMESPACE_ID}/values/${key}`, options)
const result = await response.json()
console.log("set result", result)
return result.result

}
6 replies
DTDrizzle Team
Created by fasm on 11/2/2023 in #help
Slow queries with relationships
No description
2 replies
DTDrizzle Team
Created by fasm on 5/31/2023 in #help
update multiple rows
How can I update values in multiple rows at once?
28 replies
TTCTheo's Typesafe Cult
Created by fasm on 5/23/2023 in #questions
Clerk: auth() was called but it looks like you aren't using authMiddleware in your middleware file
I'm using the nextjs app dir, and my middleware is definitely being called:
export default authMiddleware({
afterAuth: async (auth, request, evt) => {
console.log("hello from middleware")
}
});


export const config = {
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
export default authMiddleware({
afterAuth: async (auth, request, evt) => {
console.log("hello from middleware")
}
});


export const config = {
matcher: ["/((?!.*\\..*|_next).*)", "/", "/(api|trpc)(.*)"],
};
But I still get the error that I'm not using authMiddleware when I use
import { UserButton, auth } from '@clerk/nextjs';

const user = auth()
import { UserButton, auth } from '@clerk/nextjs';

const user = auth()
Any suggestions?
13 replies
TTCTheo's Typesafe Cult
Created by fasm on 5/8/2023 in #questions
Error: backingFormData.forEach is not a function
anyone else seeing this when trying to use new nextjs server actions? Error: backingFormData.forEach is not a function
export default function Home() {
async function test() {
'use server'
console.log('test')
}
return (
<form action={test}>
<button>test</button>
</form>
)
}
export default function Home() {
async function test() {
'use server'
console.log('test')
}
return (
<form action={test}>
<button>test</button>
</form>
)
}
this is all I've changed from create-react-app@latest
3 replies
TTCTheo's Typesafe Cult
Created by fasm on 4/22/2023 in #questions
vercel preview domain alias
I’m trying to follow this guide to add an alias to my GitHub CI workflow: https://vercel.com/guides/how-to-alias-a-preview-deployment-using-the-cli But I always get an error that the deployment ID cannot be found. I get the same error when trying to run the same command locally against the preview URL. Anyone else faced this/know how to achieve this?
1 replies
TTCTheo's Typesafe Cult
Created by fasm on 4/19/2023 in #questions
TRPC function type per router
I know you can run your TRPC endpoint on vercel's edge, but does anyone know if I can run some routes on serverless and some on edge? Thanks
2 replies
TTCTheo's Typesafe Cult
Created by fasm on 4/13/2023 in #questions
Stop unnecessary vercel deployments in mono-repo
I have one repo which contains two vercel projects, with both projects linked to the same git branch. At the moment, if I make a change to one project, it triggers a redeployment of both. Is there a way (perhaps with GitHub actions) to only trigger builds for projects when certain sub directories have changed? Thanks!
4 replies
TTCTheo's Typesafe Cult
Created by fasm on 1/25/2023 in #questions
Vercel functions - python + node runtimes
I need to have some vercel functions in python, and I'd like to have them live in the same project as my nextjs app. In a clean T3 app, when I make a /api folder with a python handler, I get 404s on all other functions. I think it could have something to do with how the dynamic routes are handled (https://github.com/vercel/vercel/issues/3294), but I just wondered if anyone else has encountered this?
1 replies
TTCTheo's Typesafe Cult
Created by fasm on 12/12/2022 in #questions
next export
Hey all, I’m trying use next export to convert the t3 starter website into a static site. I’m getting the error “i18n support is not compatible…”. Anyone got any advice?
6 replies