sindresorhus / public-ip

Get your public IP address - very fast!
MIT License
1.02k stars 65 forks source link

public-ip/browser `Unexpected token ?` #65

Closed Quantbase closed 2 years ago

Quantbase commented 2 years ago

Hey there, I'm seeing this issue pop-up in sentry. Haven't been able to reproduce it locally though.

https://sentry.io/share/issue/85bff94c8bde46c3ba0eeef06604cbe1/

Happens on our landing page which is pretty straightforward:

export default function Index(props) {
  const router = useRouter();
  useEffect(() => {
    // ...
    publicIpv4({ fallbackUrls: ["https://ifconfig.co/ip"] })
      .then(res => res)
      .catch(_ => "blocked")
      .then(ipAddress =>
        // ...
      );
  }, [router.isReady]);

  return (
      <IndexPage />
  );
}

Using "public-ip": "^6.0.1",

Some additional details from Sentry:

Screen Shot 2022-07-09 at 1 25 17 AM
sindresorhus commented 2 years ago

I assume it's https://github.com/sindresorhus/public-ip/blob/e8724525df3f5427cb17f96ddca23a5007a8c933/browser.js#L71

It's up to you to transpile the code if you need to support older browsers.