formigueiro
formigueiro
Explore posts from servers
NNuxt
Created by formigueiro on 10/17/2024 in #❓・help
I created middleware to use in some pages, but im checking and taking time to run
I'm trying to deny users access to certain routes, but he gets to see the content until it loads, I don't know on the client or server
3 replies
NNuxt
Created by formigueiro on 3/14/2024 in #❓・help
Error ExperimentalWarning: Importing JSON modules
someone?
2 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
i had to use vercel headers to get country
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
yes
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
🥹
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
No description
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
Is there any configuration I can test?
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
i dont know, very bizarre, if I access my endpoint through the browser (from the serverless) that I created, it takes the correct one, but if I call it either in the application directly in the route or in the project's api, it returns the address where the serverless it is
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
@SeatloN bro, I created a basic serverless here and when accessing with vercel, it takes another address
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
Could it be that if I create an api and call it, I will still receive the request with the vercel ip?
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
just Enterprise only so
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
looks like vercel its hidden client ip
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
yeah but neather over server api
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
i was doing it over .vue but ive tested it on server/api/status with
export default defineEventHandler(async (event) => {
const ip =
event.node.req.headers["x-forwarded-for"] ||
event.node.req.connection.remoteAddress || // for local dev
event.node.req.socket.remoteAddress;

return {
realip: event.node.req.headers['x-real-ip'] || event.node.req.headers['x-forwarded-for'] || event.node.ip,
forwardedfor: event.node.req.headers['x-forwarded-for'],
vercelforwardedfor: event.node.req.headers['x-vercel-forwarded-for'],
'x-forwarded-for': event.node.req.headers['x-forwarded-for'],
remoteAddress: event.node.req.connection.remoteAddress, // for local dev
remoteAddress: event.node.req.socket.remoteAddress,
'x-real-ip': event.node.req.headers['x-real-ip'],
'x-forwarded-for': event.node.req.headers['x-forwarded-for'],
'x-vercel-forwarded-for': event.node.req.headers['x-vercel-forwarded-for'],
};
});
export default defineEventHandler(async (event) => {
const ip =
event.node.req.headers["x-forwarded-for"] ||
event.node.req.connection.remoteAddress || // for local dev
event.node.req.socket.remoteAddress;

return {
realip: event.node.req.headers['x-real-ip'] || event.node.req.headers['x-forwarded-for'] || event.node.ip,
forwardedfor: event.node.req.headers['x-forwarded-for'],
vercelforwardedfor: event.node.req.headers['x-vercel-forwarded-for'],
'x-forwarded-for': event.node.req.headers['x-forwarded-for'],
remoteAddress: event.node.req.connection.remoteAddress, // for local dev
remoteAddress: event.node.req.socket.remoteAddress,
'x-real-ip': event.node.req.headers['x-real-ip'],
'x-forwarded-for': event.node.req.headers['x-forwarded-for'],
'x-vercel-forwarded-for': event.node.req.headers['x-vercel-forwarded-for'],
};
});
its not returning the truth ip
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
The vercel is returning the ip apparently where the application is. If I access it by using a VPN to test it, it always returns to the country where the application is.
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
export default function useUserAgent() {
if (process.server) {
const nuxtApp = useNuxtApp()

if (nuxtApp.ssrContext && nuxtApp.ssrContext.event.node.req) {
const ip =
nuxtApp.ssrContext.event.node.req.headers["x-forwarded-for"] ||
nuxtApp.ssrContext.event.node.req.connection.remoteAddress || // for local dev
nuxtApp.ssrContext.event.node.req.socket.remoteAddress;

console.log("realip", nuxtApp.ssrContext.event.node.req.headers["x-real-ip"]);
console.log("forwardedfor", nuxtApp.ssrContext.event.node.req.headers["x-forwarded-for"]);
console.log("vercelforwardedfor", nuxtApp.ssrContext.event.node.req.headers["x-vercel-forwarded-for"]);
console.log("x-vercel-ip-country", nuxtApp.ssrContext.event.node.req.headers["x-vercel-ip-country"]);

const ua = nuxtApp.ssrContext.event.node.req.headers["user-agent"];

const device = setDevice(ua)

return {
userAgent: ua || "",
ip: typeof ip === "string" ? ip : undefined,
device
};
}
}
return {
userAgent: ua,
ip: undefined,
device
};
}
export default function useUserAgent() {
if (process.server) {
const nuxtApp = useNuxtApp()

if (nuxtApp.ssrContext && nuxtApp.ssrContext.event.node.req) {
const ip =
nuxtApp.ssrContext.event.node.req.headers["x-forwarded-for"] ||
nuxtApp.ssrContext.event.node.req.connection.remoteAddress || // for local dev
nuxtApp.ssrContext.event.node.req.socket.remoteAddress;

console.log("realip", nuxtApp.ssrContext.event.node.req.headers["x-real-ip"]);
console.log("forwardedfor", nuxtApp.ssrContext.event.node.req.headers["x-forwarded-for"]);
console.log("vercelforwardedfor", nuxtApp.ssrContext.event.node.req.headers["x-vercel-forwarded-for"]);
console.log("x-vercel-ip-country", nuxtApp.ssrContext.event.node.req.headers["x-vercel-ip-country"]);

const ua = nuxtApp.ssrContext.event.node.req.headers["user-agent"];

const device = setDevice(ua)

return {
userAgent: ua || "",
ip: typeof ip === "string" ? ip : undefined,
device
};
}
}
return {
userAgent: ua,
ip: undefined,
device
};
}
my composable
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
@SeatloN
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
im using this but return the current ip from where my app is
32 replies
NNuxt
Created by formigueiro on 5/31/2023 in #❓・help
GeoIP-lite with nuxt3
Ok, i create a server api but mu app its on vercel and its no getting the true user ip.
32 replies