Next.js Discord

Discord Forum

redirect based on the user's IP address. Geo Redirect

Answered
Alaska pollock posted this in #help-forum
Open in Discord
Alaska pollockOP
Hello. I'm trying to implement the following logic. if the user has an Indonesian IP address and tries to access example.com, then he will be redirected to example.id, if the user has a non-Indonesia IP address, then when he tries to access example.id, he will be redirected to example.com. I implemented this logic through the middleware as indicated in the vercel documentation. but the problem is that the site example.com is blocked in Indonesia, when I try to open this site from an Indonesian IP address, I get the error net:err_cert_common_name_invalid, that is, the middleware does not even have time to work to complete the redirect. How can this problem be solved? if a user from a non-Indonesian IP address tries to open example.id, then everything works without problems, a redirect occurs to example.com
Answered by joulev
if the indonesian ISPs block the example.com domain, there isn't anything you can do, really. many big websites like BBC are blocked in some regions too and there isn't anything they can do about it.
View full answer

8 Replies

Answer
just need to do a redirect if a user from Indonesia tries to go to example.com. I heard that some DNS providers provide redirect capabilities based on the user’s geolocation. but we have a DNS address on namechip and it doesn’t provide anything like that
@Alaska pollock Is there really no mechanism to solve this problem? because example.id is not blocked in Indonesia
when users access example.com, browsers only send the request to example.com. as far as browsers are concerned, example.com and example.id are completely separate websites so there isn't a reason for them to even think about example.id when the user accesses example.com
@Alaska pollock just need to do a redirect if a user from Indonesia tries to go to example.com. I heard that some DNS providers provide redirect capabilities based on the user’s geolocation. but we have a DNS address on namechip and it doesn’t provide anything like that
no. since example.com is blocked by the ISP themselves, the request will be blocked before it even reaches your namecheap (or wherever you have your domain nameservers)
there isn't anything you can do here. that's the harsh truth of government censorship.
you can tell your users to use VPNs or switch ISP or whatever, but there isn't anything you can do to bypass the block imposed by the ISP