De Bok
De Bok
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
This is very cool. thanks for all the info!
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
The built-in proxy is very nice. It is was one of the selling points for using Solid Start in the first place. My other option would've been to make the API the entry-point to my app, and have the API serve a SolidJS SPA. The second approach is probably more conventional, but I like proxying API requests through a frontend framework for some reason.
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
Yeah. I think you are right. There are some footguns in that approach, but I've used it before in another project with a different framework. I was just hoping SolidStart would have something more convenient. Thanks for taking the time to help out with this!
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
Oh. My apologies if I misunderstood. You can't add your own nitro middleware to Solid Start. I tried it, and it didn't work. That is why I opened the discussion. What I am trying to figure out is if I can do one of these 2 things: 1. Add a middleware that wraps everything, including routes proxied through nitro. or if that isn't possible 2. Proxy the external API requests in a different way so that they are effectively covered by the SolidStart middleware.
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
I don't know, but the reliance on vinxi and nitro is well documented. I also don't think that these kind of what-ifs are really constructive. I migrated my app from Svelte to Solidjs recently. I never asked myself "what if Svelte introduces runes, and starts imitating Solidjs." But when it happened, I made a decision, and I believe it was the right one. So if SolidStart stops using nitro,and it breaks my app, I will make a decision and hope for the best.
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
Yes, that's how I understand it. When you run npm run build, it calls through to vinxi build. Vinxi then configures a nitro server for you based off your app.config.ts, and nitro is what ends up serving the production application.
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
I got to a fair amount of depth trying to figure it out. The feature that is documented is this: SolidStart uses vixni, which uses uses Nitro in production, Nitro allows for proxying in production by use of the routeRules. This is why I tried to use Nitro's middleware to try and wrap the proxied requests, but it seems that vixni overrides Nitro's handlers. So I came to ask here with the hope that I was missing something.
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
How else would you access an external API in production?
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
Wouldn't that be the devProxy option?
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
Well, the console print-out would be step 1. If I can print it on the terminal, I can do more things. I don't consider the browser a good place to trace errors, as it is ephemeral, especially when a non-technical user encounter these errors. If I encounter an error I would like for it to be logged and e-mailed with as much information as I have access to.
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
I get an error on the browser (reporting a 502 or 503), however I don't get anything on the terminal, or on a log that I can use to debug.
34 replies
SSolidJS
Created by De Bok on 3/5/2025 in #support
Middleware around API proxy
Part of the problem that I am trying to solve here, is that if the external API is down, I have no way of knowing. The other thing is that it would be nice to have logging attached to that proxy request. The way I see it, the best way of doing this would be to wrap the entire application in a middleware.
34 replies