Kasper
API Proxy in SolidStart
In my application we have a dedicated API backend, on
api.example.com
, in our vite configuration we have set up a proxy forward with the config below. However when we deply the server with the content from dist/
it dose not use vite to serve the content, but the SolidStart server, are there a way to this "production" to also proxy the requests?
2 replies
Running tests in docker fails, but works outside of docker
I am attempting to set up a Docker development environment for a SolidJS application using Docker Compose. When I access the webpage via localhost:3000, the application renders without issues. However, when I attempt to run npm test using vitest inside the Docker container, I run into a problem. The issue appears to be with the render function, as it does not seem to render the application correctly within the Docker container. The debug output only shows
<body><div /><body>
. Interestingly, when I run npm test outside the Docker container on my local machine, the test passes just fine and the debug correctly renders the application.
Here's the relevant code from my test file:
My test file:
The App.tsx file:
The npm test
output
My docker files:
6 replies
Component is not updated when prop is changed
I have a component "ShowDocument" with a resource inside, the component has a variables that needs to used in the resources. The component is called with the following:
<ShowDocument documentId={showDoc()} onClose={closePanel} />
my issues is that when signal showDoc()
in the prop "documentId" is updated the component ShowDocument
is not updated, and will continue to show what was there when it was first rendered.
34 replies
Right way of getting errors out of async context functions
I have a context that has methods that are async, the method itself on the context is sync, but that calls an Async method. This async method can throw an Unauthorized exception, it that happens i would like to redirect the user to "/signin". Would the correct way here be to have "error" signal that is read somewhere else on the UI thread and if that contains an error throw it, or are there a better way to do this?
2 replies
Avoid Provider nesting
I am going to have a lot of Providers in my App, and i did not want to have 5+ nesting around my rotes.
Here is the example with just 2 providers:
So i though i could put all my providers into to a single component, and then only have 1 "Provider" around my Routes. However when i do this, i can see from logging that my providers are created, but non of the sub-components have assess to the useUser or useProtfolios as they are undefined. This works fine when i have the providers around my rote but not when i wrap them in a component. Should the following not work?
App.tsx i replace the 2 providers with <AppProviders>...</AppProviders>
4 replies
Guide for more complex usage of stores
Were can i find a more complex guid of how to use SolidJS stores. The example i wanted to do is to have a store of transactions, i will have a component to list all transactions, a component to create a new transaction with a parent page to contain it all. Down in the list component is a child component for each transaction. In the child component i can delete the given transaction, when this is done i would like to send a signal to the store that it needs to re-fetch the list of transactions, same when a new transaction is added. From what i understand from the tutorials i need to have the store i a separate file that gets included. But i can't really figure out what the best practice is here, and how can i have a single place where "fetch" logic is, so i don't have to copy it for the child component and the new transaction component.
30 replies
How to getUser without doing a server request on every page.
I am following the guide on https://tahazsh.com/blog/building-a-solidjs-app-from-scratch/ (expanding on the session in the https://start.solidjs.com/advanced/session) to create a authentication system in SolidJS Start. It works fine but it loads the if i want to use in a page, it dose a POST request to the backend server each time the page is loaded. How can i cache the user in the client, that also updates if the user logs out.
The get user, i though i could add it to the token, but i would have to redirect the user with the new headder to store it.
In react without SSR, it would just store the user in local storage, would that also be the right way to do here, as i guess that would cause problems with the SSR?
7 replies