farmOS / farmOS.js

A JavaScript library for working with farmOS data structures and interacting with farmOS servers.
MIT License
15 stars 13 forks source link

Fix `remote.add()`. #59

Closed jgaehring closed 2 years ago

jgaehring commented 2 years ago

From https://github.com/farmOS/farmOS-client/issues/468#issuecomment-1004115085:

Hmm, well there's still something wrong with the origin not being used the first time you try to log in; it now seems to be using a relative URL, /oauth/token. I suspect this is a bug with the remote.add() method I replaced remote.setHost with in farmOS/farmOS.js@7781ec7. So when a fresh install of FK first starts up, it has a host of '', which should be changed to 'https://test.farmos.dev' when you log in, but that doesn't appear to be happening.

I think the issue is here:

https://github.com/farmOS/farmOS.js/blob/7781ec7574bcb23f05b1c983633d819bca77ed3f/src/index.js#L68

I should probably be using this instead of farm.

jgaehring commented 2 years ago

Actually, I'm pretty sure I was wrong about this. The problem seems to be in FK, where the new host is being overwritten inadvertantly in the setHost helper. It should be resolved by farmOS/farmOS-client@cdd76bf.

For good measure I also added an extra test to verify remote.add() should be working (e244309), and also caught another bug that should be fixed now (21996ff). Bumped it up to beta.5 for those changes.