npm.io
1.9.0-dev.1426 • Published 10 months ago

@fedify/express

Licence
MIT
Version
1.9.0-dev.1426
Deps
0
Size
6 kB
Vulns
0
Weekly
2.5K

@fedify/express: Integrate Fedify with Express

npm Matrix @fedify@hollo.social

This package provides a simple way to integrate Fedify with Express.

The integration code looks like this:

import express from "express";
import { integrateFederation } from "@fedify/express";
import { federation } from "./federation.ts";  // Your `Federation` instance

export const app = express();

app.set("trust proxy", true);

app.use(integrateFederation(federation, (req) => "context data goes here"));

Reverse proxy with Express 4.x

If your application uses Express 4.x behind a reverse proxy with a non-standard port (e.g., Host: example.com:8080), the reconstructed request URL may lose the port number. This is because Express 4.x's req.host (which respects trust proxy) strips the port from the Host header.

This issue does not occur with Express 5.x, where req.host retains the port. If you rely on trust proxy and your origin includes a non-standard port, we recommend upgrading to Express 5.

Keywords