snnsnn
Explore posts from serversBest Practices for Handling Errors in a query-Wrapped Server Function
Hey everyone! I’ve been working with SolidStart and have a question about error handling and display strategies for server functions wrapped in a query. The example below is inspired by one of the official SolidStart examples:
In this example, if the user isn’t found, the current approach redirects to the login page. However, for a different scenario, I’d like to display an error message in the UI instead of redirecting.
I’m considering a couple of approaches:
1. Relying on Error Boundaries to catch and render the error.
2. Returning a value (e.g., { data: ..., error: ... }) that includes potential errors so I can display the appropriate state in the receiving component.
What do you think is the best way to handle this in SolidStart? I’d love to hear your thoughts and how you approach similar cases in your projects.
Thanks in advance.
7 replies
Seeking Insights on SolidStart Server Function Issue
Hi everyone! I've encountered a strange behavior in a SolidStart project involving server functions and page refreshes. I've detailed the issue, steps to reproduce, and provided a demo repo and code examples here: GitHub Issue.
If anyone has insights or suggestions, I'd greatly appreciate your input!
7 replies
Registering API Endpoints on SolidStart
Hi everyone! I’m exploring ways to programmatically register API endpoints in SolidStart without relying on
FileRoutes
. My goal is to fully control the paths manually instead of using the file-based routing system.
I know it’s possible to do this using a middleware like so:
While this works, I’m wondering if there’s a simpler or more straightforward alternative.
Additionally, does the Solid Router support adding API endpoints directly, or is there a recommended way to handle API routing with it?
Using a middleware as shown above, is there a built-in utility in SolidStart to match routes and extract query parameters from the request? If so, how can it be used within the middleware?
I’d appreciate any guidance, examples, or tips. Thanks in advance!3 replies
CDCloudflare Developers
•Created by snnsnn on 8/19/2024 in #pages-help
Do middlewares are counted as functions?
Hi everyone, I am new to cloudflare and trying to learn pages.
On the pages websites, it is said "On both free and paid plans, requests to static assets are free and unlimited. A request is considered static when it does not invoke Functions."
https://developers.cloudflare.com/pages/functions/pricing/#static-asset-requests
I was wondering if invoking a middleware is counted as invoking a function. To be more specific, I am using
functions/_middleware.js
to serve static assets and I am not sure if such a middleware incur cost for serving a static file.
If so, is there a way to serve those static files without a middleware?9 replies