Accessing request object in the Route.loader
I would like to get access to request headers in the loader to get the IP address (to display that the service is not available in certain countries).
What is the proper way of getting access to the request object / headers in the loader?
I have tried adding
getHeader
but that causes a build error.
2 Replies
fair-roseOP•4mo ago
I ended up defining a server fn and calling the server fn in the loader.
metropolitan-bronze•4mo ago
that's the way
loaders are isomorphic, which means they run on both client and server
hence if you need something to always run on the server, you need to wrap into a server function