Skip to content
Advertisement

Send website visitor IP when accessing website

I am working on a personal project and I was wondering why not use a kind of ip logger that logs the ip of a visitor and sends it to a Discord webhook. The code works, but only locally. I tried hosting the code on Glitch but i was getting this error in the console:

JavaScript

grab.js:

JavaScript

index.html:

JavaScript

Advertisement

Answer

This answer covers most of the grounds of your error, to just be short I would like to diagnose your error for you and tell you this:

“No Access-Control-Allow-Origin header” problems ply through the CORS Policy as it considers your script malicious ( since it obviously is an IP grabber ) you can work your where around this via a CORS proxy which you can set up with the linked answer above.

Also Chromium does not allow CORS on localhost that’s why you weren’t facing the issue there.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement