-
-
Notifications
You must be signed in to change notification settings - Fork 42
Automatically recognize environment variables as fallbacks #9
Comments
Hi @davidmeirlevy! For instance, if you look at the React.js starter: import Fastify from 'fastify'
import FastifyVite from 'fastify-vite'
import FastifyDXReact from 'fastify-dx-react'
const server = Fastify()
server.decorate('db', {
todoList: [
'Do laundry',
'Respond to emails',
'Write report',
]
})
server.put('/api/todo/items', (req, reply) => {
server.db.todoList.push(req.body.item)
reply.send({ ok: true })
})
server.delete('/api/todo/items', (req, reply) => {
server.db.todoList.splice(req.body.index, 1)
reply.send({ ok: true })
})
await server.register(FastifyVite, {
root: import.meta.url,
renderer: FastifyDXReact,
})
await server.vite.ready()
await server.listen(3000) You're free to set a port at the Fastify level: await server.listen(process.env?.PORT ?? 3000) is that what you were referring to? |
Yep. @galvez changed it. I then exposed the port and ip from my server file, and the package used them: I need to change fastify-vite to dx, but unfortunately it will take me a week or two. |
@micheleriva We also have a prototype for a CLI (the |
Renamed this issue and added |
Just a follow up on this issue — I've been working on getting |
The fallback for the default port should first fallback to process.env.PORT || 3000, and not directly to 3000.
The text was updated successfully, but these errors were encountered: