remult / remult

Full-stack CRUD, simplified, with SSOT TypeScript entities
https://remult.dev
MIT License
2.88k stars 125 forks source link

403 status livequery custom monorepo todo app #355

Closed bensos000 closed 7 months ago

bensos000 commented 7 months ago

when i want to have livequery fetch data in authenticated method it return 403. here is the code in github: https://github.com/bensos000/remultmonorepo run it and when it authenticate it will return 403 for tasks list. can you correct the code ?

noam-honig commented 7 months ago

I'll look into it Sunday morning

yoni-rapoport commented 7 months ago

This seems to be a cookie issue with bun and cookie-session. Did you try NodeJS?

noam-honig commented 7 months ago

Hi @bensos000, we've looked deeper into this, and it seems that the issue here is a problem with the node js package called cookie-session that doesn't work correctly - and starts a new session on each request.

So, once you sign in, and set the user in the session, that user is not in the session in the next request. You can replace the cookie session usage with any other cookie session implementation that is popular in ban and it'll probably work

bensos000 commented 7 months ago

@noam-honig thanks i will try it and confirm it if it works

bensos000 commented 7 months ago

i confirm it works with hono and hono-sessions middleware https://github.com/bensos000/remultmonorepo image

bensos000 commented 7 months ago

when i try to make some crud operations from the frontend it returns this image image

i think the payload returned from repo in the controller is not right image

but it works when listing all todos in liveQuery

noam-honig commented 7 months ago

Can you share the code?

bensos000 commented 7 months ago

the code is in the same repo i have commited hono remult server with the new changes in the main branch => https://github.com/bensos000/remultmonorepo

noam-honig commented 7 months ago

It seems that you have two versions of remult - one exp in the backend and one 25.5 in the shared. - causing to instances of remult to run in memory.

Can you please align both package.json

bensos000 commented 7 months ago

i have updated the version of remult to exp in shared package and the same problem persist.

yoni-rapoport commented 7 months ago

You probably still have duplicate remult packages (two node_modules/remult folders) installed somewhere in your project tree.

While we'd like to fix remult to handle these situations better, having only one instance of the package in your tree is better.

Try deleting all remult folders and re-running bun install.

bensos000 commented 7 months ago

yes you're right image i have shared now only one instance of remult throught the backend package and i confirm it works now image

noam-honig commented 7 months ago

Can you check this out in the latest version, I think it's fixed by now

bensos000 commented 7 months ago

i have made 2 remult instances in the monorepo like this : image image and i confirm it works now: image

noam-honig commented 7 months ago

Perfect.

One more thing, if you want to contribute an example project that shows bun, hono and hono-sessions - it would be a great contribution.

Simply add it to: https://github.com/remult/remult/tree/master/examples

bensos000 commented 7 months ago

ok i will make a pull request with an example of bun-hono-monorepo-todo

bensos000 commented 7 months ago

here is the pr : https://github.com/remult/remult/pull/375

noam-honig commented 7 months ago

Thanks - I've merged it