doxr
1
Hello, Ask.
So I’ve been trying to start a web app (NodeJS) and I have this code, it uses Fastify
const fastify = require('fastify');
const app = fastify();
app.route({
method: 'GET',
url: '/',
handler: (req, reply) => {
reply.sendFile('index.html', './');
}
});
app.listen({ port: 3000 });
It… looks like it started, but it didn’t. The Replit authentication tab shows this too.

I thought it was an error in the code (there are no errors in console) but then I have this code (uses Express)
const express = require('express');
const app = express();
const path = require('path');
app.use(express.static(path.join(__dirname, '/')));
app.get('/', (req, res) => {
res.sendFile('/index.html', {
root: path.join(__dirname, './')
});
}
});
app.listen(3000, () => console.log(`Port 3000`));
but this works??
I think this is a bug, but this could be a code question. I don’t really know.
I made a repl: https://replit.com/@doxr/fastify-fail#index.js
Fastify might not be supported? I don’t know why it wouldn’t work.
doxr
3
How so? And it used to work. Also, if it was not supported I think there would be a warning.
I’ll try it out in a fork
doxr
5
Looks like it breaks on everyone’s repls, not just mine 
2 Likes
Just tried this myself and I couldn’t get it working either 
With fastify, try specifying to run the Repl on the host 0.0.0.0
Express does that by default.
3 Likes
doxr
9
OK I’ll try it and edit this message.
Edit: sorry for the late edit, @ReplitIronclad, but it seems to work by updating this line:
app.listen({ port: 3000, host: '0.0.0.0' });
but now the site shows this:
{“statusCode”:500,“error”:“Internal Server Error”,“message”:“reply.sendFile is not a function”}
It’s probably something related to the code. If you have any ideas then please help, otherwise thanks!
Edit 2:
Fixed, I made the same repl a template, because I usually need it as a template and this is good.
2 Likes
system
Closed
11
This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.