Skip to content
  • Unlock Pro
  • Log in with GitHub
Solution
Submitted about 4 years ago

IP Tracker - Mobile first, Sass, Environment variable, Webpack, JS

tediko•6,700
@tediko
A solution to the IP Address Tracker challenge
View live sitePreview (opens in new tab)View codeCode (opens in new tab)

Solution retrospective


Hello👋!

Im surprised how much I learned from a seemingly easy challenge. I ran into problems with CORS on firefox and lost a lot of time trying to figure it out. Hopefully I found solution. List of things I learned or used creating this project:

  • This is first time I used webpack. And more specifically I used laravel mix which is a wrapper for webpack and targets the 80% usecase. I didn't realize how powerful tool it is. LINK
  • Implement an environment variable (link) for my API_KEY. This is a variable whose value is set outside the program to secure our sensitive data. I did it with serverless Lambda function on netlify, so my API_KEY never shows up in my code and no one will steal it. Tutorial
  • This is first time I used object literals (link) instead of if statement in Tracker.changeContent function. Shortly, we have an object where the keys are the conditions and the values are the responses. Then we can use the square bracket notation to select the correct value of the object from the argument passed in. This looks clean and I will definitely continue to use this.
  • Added aria-live="polite" and aria-atomic="true" to my .tracker__results-wrapper element to expose dynamic content changes in a way that can be announced by assistive technologies after my results inner elements change content.
  • I didn't like that results container with address informations cover the map and user can't do anything with that. Added button to hide that container. More useful on mobile tho.

Errors that I encountered:

  • The problem I talked about is only on Firefox. Console throws an CORS error -> Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource. It turned out that after the recent firefox update you cannot fetch data between different origins. The fix is to send request to a proxy. A proxy acts as an intermediary between a client and server. The proxy server operates in between the frontend web app making the request, and the server that responds with data. Simply add https://cors.bridged.cc/ to any URL you’re fetching from or use cors-anywhere. Read about this CORS error. Since i work with serverless function on netlify i didn't have to put this in my fetch, because netlify fetching that data for me. But i think that info will be helpful for others.
  • Since we're using proxy, we have to somehow get user IP if we want to display user info on init. That is because geo api will return proxy ip address on default. I use cloudflare trace utility to work around this problem. It retunrs a plain-text set of key/value pairs.

Special thanks to @brasspetals for total help, @mattstuddert for helping with these CORS problems and @grace-snow for for throwing the link with object literals on slack. No specific questions here but any additional feedback will be appreciated! Thanks! 😁

Code
Select a file

Please log in to post a comment

Log in with GitHub

Community feedback

  • Matt Studdert•13,611
    @mattstuddert
    Posted about 4 years ago

    Another amazing solution, Tediko! I love the additional details of the transition when changing location and the hide details toggle. Really useful for others to see all the extra stuff that went into this project, like hiding the API key and the issues you encountered.

    Very nice work! 🙌

  • Arinze Owoh•150
    @ArinzeGit
    Posted about 1 year ago

    Very nice solution. I am currently building mine. I really love your animations that I keep reloading the page. I hope I don't finish your API credits.

  • ApplePieGiraffe•30,525
    @ApplePieGiraffe
    Posted about 4 years ago

    Greetings, tediko! 👋

    Very, very nice job on this challenge! 🙌 Your solution looks great and works very well (and the animation you added to the map is awesome)! 😀 I like the extra details you added such as the option to close the information box! 👏

    Just one or two tiny suggestions—I think something like cursor: text (rather than cursor: pointer) would work a little better for the input element itself (since a user would type into the search box). And this definitely just extra (since I know there's already the icon for this)—but some text inside the collapsed information box to indicate its function or state (like "Show Details" or something, IDK) might be a nice touch! 😉

    I'm curious—was adding the zoom out and slide transition to the map very difficult? Or was it easy to add with the map or something? 🙂

    Of course—keep coding (and happy coding, too)! 😁

  • Anna Leigh•5,135
    @brasspetals
    Posted about 4 years ago

    Tediko this is AWESOME! I really love the loader animation, as well as the map movement/animation as it zooms to your location. So cool! 🙌 Also, big thank you for all the resources you've linked here and in your README. 🙏

    Thanks for the shoutout, although wouldn't say I "helped" - I tried at least! Moral support! 😂

    The only small thing I noticed is that you're missing the slight box-shadow on the #results that's in the design.

  • Praneet Dixit•120
    @PraneetDixit
    Posted about 4 years ago

    I loved the hide details option. The details section hiding the map is very annoying in mobile phones.

  • Michal•665
    @mbart13
    Posted about 4 years ago

    I wish I'd thought of this hiding map button, cool :)

    Also, I don't know why it's showing incorrect location for me, it used to work correct. Maybe they changed API...

Join our Discord community

Join thousands of Frontend Mentor community members taking the challenges, sharing resources, helping each other, and chatting about all things front-end!

Join our Discord
Frontend Mentor logo

Stay up to datewith new challenges, featured solutions, selected articles, and our latest news

Frontend Mentor

  • Unlock Pro
  • Contact us
  • FAQs
  • Become a partner

Explore

  • Learning paths
  • Challenges
  • Solutions
  • Articles

Community

  • Discord
  • Guidelines

For companies

  • Hire developers
  • Train developers
© Frontend Mentor 2019 - 2025
  • Terms
  • Cookie Policy
  • Privacy Policy
  • License

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

How does the accessibility report work?

When a solution is submitted, we use axe-core to run an automated audit of your code.

This picks out common accessibility issues like not using semantic HTML and not having proper heading hierarchies, among others.

This automated audit is fairly surface level, so we encourage to you review the project and code in more detail with accessibility best practices in mind.

How does the CSS report work?

When a solution is submitted, we use stylelint to run an automated check on the CSS code.

We've added some of our own linting rules based on recommended best practices. These rules are prefixed with frontend-mentor/ which you'll see at the top of each issue in the report.

The report will audit all CSS, SCSS and Less files in your repository.

How does the HTML validation report work?

When a solution is submitted, we use html-validate to run an automated check on the HTML code.

The report picks out common HTML issues such as not using headings within section elements and incorrect nesting of elements, among others.

Note that the report can pick up “invalid” attributes, which some frameworks automatically add to the HTML. These attributes are crucial for how the frameworks function, although they’re technically not valid HTML. As such, some projects can show up with many HTML validation errors, which are benign and are a necessary part of the framework.

How does the JavaScript validation report work?

When a solution is submitted, we use eslint to run an automated check on the JavaScript code.

The report picks out common JavaScript issues such as not using semicolons and using var instead of let or const, among others.

The report will audit all JS and JSX files in your repository. We currently do not support Typescript or other frontend frameworks.

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Frontend Mentor for Teams

Frontend Mentor for Teams helps companies and schools onboard and train developers through project-based learning. Our industry-standard projects give developers hands-on experience tackling real coding problems, helping them master their craft.

If you work in a company or are a student in a coding school, feel free to share Frontend Mentor for Teams with your manager or instructor, as they may use it to help with your coding education.

Learn more

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub

Oops! 😬

You need to be logged in before you can do that.

Log in with GitHub