I made a basic fastify server listening on port 3000. It works fine locally when I curl http://localhost:3000/ in the Replit shell.
How can I get the public link so I can use the endpoint? I’ve tried the url syntax https://<my-repl-name>.<my-username>.repl.co/, but keep getting the following page instead of an API response
Hey!
I played around with your repl for a minute, found that if you add host: "0.0.0.0" after the port it works!
Here is the working code!
const fastify = require('fastify')({
logger: true
})
// Declare a route
fastify.get('/', function (_request, response) {
response.send({ hello: 'world' })
})
// Run the server!
fastify.listen({ port: 3000, host: "0.0.0.0" }, function (err, _address) {
if (err) {
fastify.log.error(err)
process.exit(1)
}
// Server is now listening on ${address}
})