Solid
prevent useAsyncData from running in the browser
I am using useAsyncData to see if the user has permission to view the page. I have created a helper function that assists in doing so. It simply returns a promise evaluating to a boolean if the user has permission or not. This logic uses sequelize to make a database request in order to see if the user has permission.
I have noticed that useAsyncData also executes on the client. This results in the client calling sequelize functions which relies on nodejs which makes the browser spit an error.
500 buffer not defined
I have tried using import.meta to prevent the code from executing on the client but o import.meta variables would work and it would execute in the browser anyway.
This is the current code
19 replies
Way to pass data between route middleware and page
I am trying to make a authentication middleware and because I am looking for something very specific I cannot resort to already made tools. The basic gist of it, like many auth middlewares, is to route to a 'login' page if the user has no permission and route to the right page if the user does have permission.
I managed to get this far, but the issue now comes when I want to add content to this page that also varies depending on the user (some users have permission to see certain things). My thought was that I could pass this 'session' to the page from the middleware. I have tried things like setting context, meta and also useState. None of them seem to work.
It is required that the user MUST NOT get to edit and SHOULD NOT see the data that is passed from the middleware to the page
At this point I don't even know if it is possible. The documentation on middleware isn't incredibly extensive and not many people have made tutorials on it. My own attempts have not yet gotten me any further. I am asking as a last resort before rethinking my website architecture
5 replies