Closed Tommypop2 closed 1 week ago
There is a really awkward problem here and it is that somewhere lower in the stack.. trailing /
versus not has different behavior most notable though is that we need to omit the trailing slash in POST, and include them in GET. The standard server function assumes the URL is for POST endpoint and returns without the trailing slash. So you need to grab the URL off the GET.. Either by using our wrapper function for TS (the public API).. GET(serverFunction).url
with GET
imported from "@solidjs/start"
or by using the internal serverFunction.GET.url
. I believe with this you don't need send args unless you intend to.
So the plan will be you could do something like:
const serverFunction = () => {
'use server';
return new Response('Hello', { headers: [["X-Content-Raw", "true"]]});
};
export default function Home() {
onMount(async () => {
const res = await fetch(serverFunction.GET.url);
console.log(await res.text());
});
Generally though I recommend wrapping the serverFunction itself with GET()
as it is unlikely you expect different callers to change the HTTP method but just putting that out.
Anyway in the course of setting the raw response I found issues with GET being wrapped by HMR proxy which stopped URL from coming through. So yeah it won't work until the next release because of a number of bugs but I think I got this figured out now.
Duplicates
Latest version
Current behavior 😯
Making a GET request to the correct endpoint with
serverFunction.url
, as well as theargs
query param results in an error:Expected behavior 🤔
The response from the server function should be sent verbatim to the client.
Steps to reproduce 🕹
Steps:
Context 🔦
I have attempted to fix this myself by patching Start: I rewrote this To this
This fixes the issue, but overwrites behaviour that I honestly don't fully understand.
Your environment 🌎
No response