Astro + env vars
I really want to use cloudflare, but every time I stumble upon errors or documentation gaps. Let's see if I can come out from this one:
I'm building an Astro application with the cloudflare adapter. I've already built one in the past, and on the old, I was using
But for this new one, it seems like they don't work.
I've read the documentation in Astro, and it says that I need to use
ok. I keep reading. It looks like I need a wrangler.toml file, but I already have the pages configured through the dashboard and I have no idea how to translate those. Luckily, there is a command
Error: listen EADDRINUSE: address already in use ::1:8976
at Server.setupListenHandle [as _listen2] (node:net:1872:16)
at listenInCluster (node:net:1920:12)
at GetAddrInfoReqWrap.doListen [as callback] (node:net:2075:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:8)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1899:8)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::1',
port: 8976
}
I just want to deploy Astro with env variables. Can someone help?
I'm building an Astro application with the cloudflare adapter. I've already built one in the past, and on the old, I was using
import.meta.env for environment variables with no problem.But for this new one, it seems like they don't work.
I've read the documentation in Astro, and it says that I need to use
proxyRuntime: { enabled: true } and then access them through const { env } = Astro.locals.runtime, which is weird because this means that I know have to pass the secrets around? Can't I use env variables at build time to set things like the db url or stripe tokens?ok. I keep reading. It looks like I need a wrangler.toml file, but I already have the pages configured through the dashboard and I have no idea how to translate those. Luckily, there is a command
npx wrangler pages download config that is supposed to do that. But when I run it I hit:Error: listen EADDRINUSE: address already in use ::1:8976
at Server.setupListenHandle [as _listen2] (node:net:1872:16)
at listenInCluster (node:net:1920:12)
at GetAddrInfoReqWrap.doListen [as callback] (node:net:2075:7)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (node:dns:109:8)
Emitted 'error' event on Server instance at:
at emitErrorNT (node:net:1899:8)
at process.processTicksAndRejections (node:internal/process/task_queues:82:21) {
code: 'EADDRINUSE',
errno: -48,
syscall: 'listen',
address: '::1',
port: 8976
}
I just want to deploy Astro with env variables. Can someone help?
