Commit 61647bb6 authored by ChanHaeng Lee's avatar ChanHaeng Lee
Browse files

Remove `x-forwarded-fetch`

https://github.com/fedify-dev/fedify/pull/355#discussion_r2258738135
If you need it, you can use this instead of `fedifyWith`:
```ts
// middleware.ts
import { hasFederationAcceptHeader, integrateFederation } from "@fedify/next";
import { getXForwardedRequest } from "x-forwarded-fetch";

export default function middleware(request: Request) {
  if(hasFederationAcceptHeader(request) {
    integrateFederation(getXForwardedRequest(request))
  }
}
```
parent da08eb5b
Loading
Loading
Loading
Loading
+0 −3
Original line number Diff line number Diff line
@@ -48,9 +48,6 @@
    "dist/",
    "package.json"
  ],
  "dependencies": {
    "x-forwarded-fetch": "^0.2.0"
  },
  "peerDependencies": {
    "@fedify/fedify": "workspace:",
    "next": "catalog:"
+4 −8
Original line number Diff line number Diff line
@@ -12,7 +12,6 @@
import type { Federation, FederationFetchOptions } from "@fedify/fedify";
import { notFound } from "next/navigation";
import { NextResponse } from "next/server";
import { getXForwardedRequest } from "x-forwarded-fetch";

interface ContextDataFactory<TContextData> {
  (request: Request):
@@ -121,19 +120,16 @@ export function integrateFederation<TContextData>(
    undefined as TContextData,
  errorHandlers?: Partial<ErrorHandlers>,
) {
  return async (request: Request) => {
    const forwardedRequest = await getXForwardedRequest(request);
    const contextData = await contextDataFactory(forwardedRequest);
    return await federation.fetch(
      forwardedRequest,
  return async (request: Request) =>
    await federation.fetch(
      request,
      {
        contextData,
        contextData: await contextDataFactory(request),
        onNotFound: notFound,
        onNotAcceptable,
        ...errorHandlers,
      },
    );
  };
}
const onNotAcceptable = () =>
  new Response("Not acceptable", {
+0 −3
Original line number Diff line number Diff line
@@ -595,9 +595,6 @@ importers:
      next:
        specifier: 'catalog:'
        version: 15.4.6(@opentelemetry/api@1.9.0)(react-dom@19.1.0(react@19.1.0))(react@19.1.0)
      x-forwarded-fetch:
        specifier: ^0.2.0
        version: 0.2.0
    devDependencies:
      tsdown:
        specifier: 'catalog:'