UNPKG

@fleek-platform/next-on-fleek

Version:

`@fleek-platform/next-on-fleek` is a CLI tool that you can use to build and develop [Next.js](https://nextjs.org/) applications so that they can run on [Fleek Functions](https://fleek.xyz/docs/platform/fleek-functions/).

29 lines (26 loc) 854 B
/** * Adjusts the request so that it is formatted as if it were provided by Vercel * * @param request the original request received by the worker * @returns the adjusted request to pass to Next */ export function adjustRequestForVercel(request: Request): Request { const adjustedHeaders = new Headers(request.headers); if (request.cf) { adjustedHeaders.set( 'x-vercel-ip-city', encodeURIComponent(request.cf.city as string), ); adjustedHeaders.set('x-vercel-ip-country', request.cf.country as string); adjustedHeaders.set( 'x-vercel-ip-country-region', request.cf.regionCode as string, ); adjustedHeaders.set('x-vercel-ip-latitude', request.cf.latitude as string); adjustedHeaders.set( 'x-vercel-ip-longitude', request.cf.longitude as string, ); } return new Request(request, { headers: adjustedHeaders }); }