Fastify fails but Express works?

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();

  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:

Fastify might not be supported? I don’t know why it wouldn’t work.

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

Looks like it breaks on everyone’s repls, not just mine :confused:


Just tried this myself and I couldn’t get it working either :frowning:

With fastify, try specifying to run the Repl on the host

Express does that by default.


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: '' });

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.


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.