Website that recognizes user's location/IP & changes lang. based on that

前端 未结 6 575
抹茶落季
抹茶落季 2020-12-13 22:40

title is pretty clear.

My websites consists of both English-written and Spanish-written versions. You can go to the main site, which is in Spanish, by clicking http:

6条回答
  •  难免孤独
    2020-12-13 23:14

    You can do a GET request to this URL: https://api.teletext.io/api/v1/geo-ip and it will respond with some country information in JSON format. See https://teletext.io/help/geo-location-service for usage.

    If you want to implement it yourself: I've set this up by using AWS Cloudfront, Cloudfront adds a header (Cloudfront-Viewer-Country) to your request before it forwards it to the origin server that you can use. Make sure to whitelist the header in your Cloudfront distribution.

提交回复
热议问题