You don't even have to become a freelancer. Remote.com and similar companies can set you up as a portuguese employee.
I'm saying Portugal and not Spain bc I think it's better for foreigners right now. And Portugal is amazing.
Reply on news.ycombinator.com