Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: allow customizing Server Function HTTP method #902

Closed
Coretteket opened this issue Jun 6, 2023 · 5 comments
Closed

Feature request: allow customizing Server Function HTTP method #902

Coretteket opened this issue Jun 6, 2023 · 5 comments
Labels
enhancement New feature or request

Comments

@Coretteket
Copy link

Currently, all requests done on the client-side for a server$ function are POST requests. This makes sense as a default, but there are many possible use-cases for server$ for simply querying data, where a GET request would be more appropriate. This is not just semantics, with the problem I run into the impossibility of caching server$ requests on Vercel's Edge Network. Therefore, I would appreciate the option to select a different HTTP method. For context, I raised this issue for pRPC (OrJDev/prpc#73), which uses server$ for a query$ function under the hood, which therefore is limited by Solid Start.

@ryansolid
Copy link
Member

We've implemented this in Bling. It will make it's way to SolidStart.

@Coretteket
Copy link
Author

Awesome – can't wait!

@ryansolid ryansolid added the enhancement New feature or request label Dec 19, 2023
@ryansolid ryansolid changed the title Feature request: allow customizing server$ HTTP method Feature request: allow customizing Server Function HTTP method Dec 19, 2023
@Download
Copy link

Download commented Jan 6, 2024

Not sure why POST would even make sense as the default, actually...

What is the default of HTML (<form> tag without method specified)?: GET
What is the default CURL uses?: GET
What is the default of fetch?: GET

IMHO there is only one sane default for requests and that is GET...

Oh and it is not just Vercel's Edge Network. The same is true for .e.g. CloudFlare. For the same reason you should avoid adding Set-Cookie header to all responses (they won't be cached), or Authorization header to every request... A lot of servers out there are effectively disabling caching...

@lxsmnsyc
Copy link
Member

lxsmnsyc commented Jan 6, 2024

@Download The only reason POST makes sense is because the server functions utilizes the request body, something that GET cannot offer. However, GET can be potentially supported, ideally if the function has no arguments or if the arguments can be safely encoded in the url.

Other methods should work just fine

@ryansolid
Copy link
Member

This has been implemented in SolidStart in 0.5.x via the GET method.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants