Local event.getClientAddress()
When using this adapter I'm getting an error when calling event.getClientAddress() to access the IP from within hooks.server.js.
It seems like the adapter isn't overriding some default?
It also doesn't seem like anything is added to the event.platform object, should I be accessing this type of stuff from a different location?
Here is the error.
at Object.getClientAddress (file:///../test/node_modules/.deno/@[email protected]/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:510:13)
at Object.handle (/../test/src/hooks.server.js, <anonymous>:16:49)
at Module.respond (/../test/node_modules/.deno/@[email protected]/node_modules/@sveltejs/kit/src/runtime/server/respond.js, <anonymous>:282:40)
at eventLoopTick (ext:core/01_core.js:183:11)```
Hi can you provide the full Error? Your output is missing the start of the error.
It sounds similar to this: https://github.com/sveltejs/kit/issues/4873
You can't use getClientAddress during the build/prerender.
You could do something like:
// hooks.server.js
import { building } from '$app/environment';
export const handle = async ({event, resolve}) => {
if (!building) {
console.log( event.getClientAddress() );
}
return resolve(event);
};
It just depends on what you are trying to achieve.
The platform is empty yes. There is no specific platform data, see SvelteKit platform docs.