#MVPin7Days DAY 6 & 7 - Weekend EDITION 🍻
As anticipated I invested a few spare hours yesterday and today to add the actual redirect logic which completes what I wanted to achieve for this week! 🥳
What's happening in the video is the following:
- I can create a link for an #Amazon product (#Halloween mood here 🎃)
- Once I visit that link I get redirected to the closest Amazon store to me (in my case: Ireland -> Amazon UK)
You can see that if I change country (thank you @expressvpn) I get redirected to different Amazon stores. Also note that for Canada, that specific product is not available and in this case, I see a search page for similar products.
Now let's talk about technical challenges, my favourite part! 🤗
Writing the code to manage the redirect was actually surprisingly easy. It's not a small amount of code, but I managed to write it all down quite quickly and it "seemed" to work straight away locally.
This was probably easy for me because recently I spent some time writing something similar, which is actually open-source and you can check out in the links below if you are really curious 😜
(give it a ⭐️, will you?)
1️⃣➡️ https://github.com/lmammino/not-one-link …
2️⃣➡️ https://github.com/lmammino/not-one-link-lambda …
In fact, as soon as I deployed the latest version of the app, the redirect logic didn't seem to select the expected Amazon shop and it was redirecting me always to the default (Amazon [dot] com!)...
Turns out that this was a combination of a few different configuration issues on the #nginx side and on #fastify side.
Before I get into the specifics let me tell you that my current setup is roughly the following:
With this setup, by default, Fastify was not seeing the actual user IP and therefore the business logic was failing to detect the user location.
The way you fix this type of issue is by adding the X-Forwarded-For header, of which you can read more here:
This header needs to be added by Nginx when forwarding the request to Fastify.
After a lot of fiddling I found out the correct config for Nginx:
( http://nginx.org/en/docs/http/ngx_http_proxy_module.html …)
On the Fastify side, Fastify needs to be aware that it should not rely on the TCP connection source IP, but instead it should look into that X-Forwarded-For HTTP header.
Fastify can actually do this very easily, by enabling the following option:
( https://www.fastify.io/docs/latest/Server/#trustproxy …)
When this was sorted out everything worked as expected and I could finally be happy 😀
So, this completes my week!
I am quite happy with the results so far, but what's next?
This is indeed a good question! 🤔👋💀
To be honest, I haven't formulated any decent plan yet and I am aware that starting from tomorrow I will have a very limited amount of time to work on this idea...
Nonetheless, I would like to bring this idea to a slightly better shape so I can validate if it can actually be useful to people!
I want to add some important missing features (e.g. users right now can't even see the list of links they created already!) and clean up the UX a bit
At that point, once I have some feedback, I'll be able to decide whether this idea is something worth pursuing or not!
Sounds simple, in theory, by stay tuned to know how it will turn out in practice. 😝
Also, if you know anyone that makes money with the Amazon Affiliates program do let me know, they might be interested to give this idea a shot (and give me some good piece of feedback!)
That's all for today and for this week!
Thanks for staying with me so far! 😍
Enjoy the rest of your weekend ❤️
SOUNDTRACK OF THE WEEKEND 👻 --> https://open.spotify.com/playlist/37i9dQZF1E4rwfVnIqWFs2?si=aZdken9CTM2n5E5P6G6k7Q …
You can follow @loige.
Tip: mention @threader_app on a Twitter thread with the keyword “compile” to get a link to it.
Enjoy Threader? Sign up.
Since you’re here...
... we’re asking visitors like you to make a contribution to support this independent project. In these uncertain times, access to information is vital. Threader gets 1,000,000+ visits a month and our iOS Twitter client was featured as an App of the Day by Apple. Your financial support will help two developers to keep working on this app. Everyone’s contribution, big or small, is so valuable. Support Threader by becoming premium or by donating on PayPal. Thank you.