mast3rof0
CDCloudflare Developers
•Created by mast3rof0 on 5/10/2025 in #workers-help
Dev vs Production deployment
According to the documentation, when creating a project with the Vue framework, it also creates an additional worker under server/index.js. I have written a worker that interacts with the D1 service in this file. When in development (npm run dev) the worker interacts with d1 without any problems. When deploying it to production (npm run deploy), the query function works as expected, but update function does not appear to be working. I have tried watching the logs and it appears to be exectuing the function as expected, but the database never reflects any of the updates
Here is the fetch function that retrieves the data that works as expected:
if (pathname === "/api/products") {
const { results } = await env.DB.prepare(
"SELECT * FROM NxStage"
)
.bind()
.all();
return Response.json(results);
}
Here is the fetch function that writes updates. Works in dev but not in production:
if (pathname === "/api/updates") {
// console.log(params);
params.forEach(async (value, key) => {
// console.log(key, value);
console.log(
UPDATE NxStage SET Qty = ${value} WHERE ID = ${key}
)
const { results } = await env.DB.prepare(
"UPDATE NxStage SET Qty = ? WHERE ID = ?"
).bind(value, key).run()
});
return new Response(null, { status: 200 });
}
Any help is greatly appreciated. I am sure I am missing something small. This one has me perplexed.9 replies
CDCloudflare Developers
•Created by mast3rof0 on 5/8/2025 in #pages-help
Worker functions
I am building a Vue app using pages but need access to other services. In looking through the configuration, server/index.js is the entry point for worker code. Is there a way to configure multiple files for my worker configurations so I can have the service split out. As an example, have one file for KV and another for D1
I have tried deploying a functions folder but nothing in that directory seems to get compiled when running 'npm run build'
2 replies