Hi everyone, I was toying with the idea of writing an open source client for Lemmy in React Native.

However, using lemmy-js-client, I’m getting CORS issue when trying to hit the APIs for lemmy.world (and also lemmy.ml) from the browser.

I could write a proxy server or a full backend, but that feels contrary to the fediverse philosophy of not being dependant on one instance etc. Not to mention users would have to trust me, some random person, with their logins / passwords for Lemmy.

Is there a way we can have CORS enabled from * for the APIs of lemmy.world?

You are viewing a single thread.
View all comments
7 points

That’s not a good idea, because that would allow any website a logged in user visits to impersonate them (e.g. link to a malicious site posted somewhere, users click on it, JS on the site starts posting the same link in their name, more users click on it, …).

But react native doesn’t restrict cross-domain access like browsers do, so it shouldn’t be an issue in your case: https://reactnative.dev/docs/network#using-other-networking-libraries

permalink
report
reply
1 point

I planned on exporting a web version as well and I was testing there first hence the issue.

How would this allow any website to impersonate you though? The login is made via a jwt which would not be accessible if you go in another website. If I login on mysuperlemmyclient.com and then visit maliciouswebsite.com, how can maliciouswebsite access the jwt that is stored likely in a cookie of mysuperlemmyclient.com?

permalink
report
parent
reply
1 point

The user’s browser will send it along with the request depending on the samesite cookie settings.

The best solution would be if lemmy used federated identity (e.g. OIDC), not sure why they aren’t doing that.

permalink
report
parent
reply

Lemmy.World Announcements

!lemmyworld@lemmy.world

Create post

This Community is intended for posts about the Lemmy.world server by the admins.

Follow us for server news 🐘

Outages 🔥

https://status.lemmy.world

For support with issues at Lemmy.world, go to the Lemmy.world Support community.

Support e-mail

Any support requests are best sent to info@lemmy.world e-mail.

Report contact

Donations 💗

If you would like to make a donation to support the cost of running this platform, please do so at the following donation URLs.

If you can, please use / switch to Ko-Fi, it has the lowest fees for us

Join the team

Community stats

  • 472

    Monthly active users

  • 806

    Posts

  • 37K

    Comments