feat:移除了弹窗,服务器添加sls
This commit is contained in:
26
apps/telemetry-dashboard/server/dev/remote-bindings.ts
Normal file
26
apps/telemetry-dashboard/server/dev/remote-bindings.ts
Normal file
@ -0,0 +1,26 @@
|
||||
import { createRequire } from 'node:module'
|
||||
|
||||
import type { PlatformProxy } from 'wrangler'
|
||||
|
||||
import type { DashboardBindings } from '../utils/bindings'
|
||||
|
||||
let proxy: PlatformProxy<DashboardBindings> | null = null
|
||||
const require = createRequire(import.meta.url)
|
||||
|
||||
export default defineNitroPlugin(async (nitroApp) => {
|
||||
const { getPlatformProxy } = require('wrangler') as typeof import('wrangler')
|
||||
proxy = await getPlatformProxy<DashboardBindings>({
|
||||
configPath: 'wrangler.toml',
|
||||
persist: false,
|
||||
remoteBindings: true,
|
||||
})
|
||||
|
||||
nitroApp.hooks.hook('request', (event) => {
|
||||
event.context.cloudflare = { env: proxy?.env ?? {} }
|
||||
})
|
||||
|
||||
nitroApp.hooks.hook('close', async () => {
|
||||
await proxy?.dispose()
|
||||
proxy = null
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user