how can i extend the remixjs request headers object globally?

Viewed 17

I wan to be able to exted the remixjs request headers object. i want to add one [k:string]: string

the key value pair i want to add is: k = 'Direction' val: 'onboarding'

i have the following. i have created a remix.d.ts at the root of my project inside @types folder

import "@remix-run/node";

import type { DataFunctionArgs, } from "@remix-run/node";

declare module "@remix-run/node" {
  export interface LoaderArgs extends DataFunctionArgs {
    headers: {
    
    }
  }
}

inside my loaderFunction i set the request type to LoaderArgs like so.

export const loader: LoaderFunction = async ({ request }: LoaderArgs) => {

    console.log(request.headers)

    return {}
}

yet i keep getting errors. like types are incompatible or you are not implementing all the functions in the header type.

so how can i extend the request interface globally so i can use it in every request?

First half of the error in error lens second half of the error in error lens

0 Answers
Related