Skip to content
This repository was archived by the owner on Jul 29, 2025. It is now read-only.

Commit 5eef629

Browse files
committed
fix: remove binding quote
1 parent de54eb5 commit 5eef629

File tree

4 files changed

+11
-6
lines changed

4 files changed

+11
-6
lines changed

packages/vite-plugin-cloudflare-functions/src/vite/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export function CloudflarePagesFunctions(userConfig: UserConfig = {}): Plugin {
4949
if (userConfig.wrangler?.binding) {
5050
for (const [key, value] of Object.entries(userConfig.wrangler.binding)) {
5151
bindings.push('--binding');
52-
bindings.push(`${key}=\\"${value}\\"`);
52+
bindings.push(`${key}=${value}`);
5353
}
5454
}
5555
if (userConfig.wrangler?.kv) {

playground/app/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ export default defineConfig({
1616
CloudflarePagesFunctions({
1717
root: '../functions',
1818
outDir: '../../',
19-
wrangler: { log: false, kv: 'STORE' }
19+
wrangler: { log: false, kv: 'STORE', binding: { USER: 'yjl9903' } }
2020
})
2121
]
2222
});

playground/functions/api/[msg].ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@ import {
44
makeResponse
55
} from 'vite-plugin-cloudflare-functions/worker';
66

7-
export const onRequestGet = makePagesFunction(({ params }) => ({
8-
status: 'OK',
9-
data: 'Hello, ' + params.msg + '!'
10-
}));
7+
export const onRequestGet = makePagesFunction(({ params, env }) => {
8+
return {
9+
status: 'OK',
10+
data: 'Hello, ' + params.msg + '!',
11+
env
12+
};
13+
});
1114

1215
export const onRequestPost = makeRawPagesFunction(({ params }) =>
1316
makeResponse({

playground/functions/cloudflare.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ import 'vite-plugin-cloudflare-functions/worker';
88
declare module 'vite-plugin-cloudflare-functions/worker' {
99
interface PagesFunctionEnv {
1010
STORE: KVNamespace;
11+
12+
USER: string;
1113
}
1214

1315
interface PagesFunctionData {}

0 commit comments

Comments
 (0)