#Should event: APIevent have client cookies on SSR?

11 messages · Page 1 of 1 (latest)

ionic portal
#
import { type APIEvent } from "@solidjs/start/server/types";
import { app } from "./elysia";

const handler = async (event: APIEvent) => {
  return await app.handle(event.request);
};

export const GET = handler;
export const POST = handler;
export const PUT = handler;
export const PATCH = handler;
export const DELETE = handler;

In following code headers only have these

 Headers {
  "connection": "keep-alive",
  "user-agent": "Bun/1.0.26",
  "accept": "*/*",
  "host": "localhost:3000",
  "accept-encoding": "gzip, deflate, br",
}
#

What I am asking, should clients cookies be forwarded to bun?

crimson orchid
#

During SSR API routes won't receive cookies, no, since it's not the client making the request

#

You need to pass through the cookies manually inside your solid query fetch

#

use server functions avoid this since they don't do a server -> server request during SSR, instead they are just called directly, reusing the Request from the client

ionic portal
#

Big thanks. Yeah that makes sense. It's kind of like using axios you need to remember to add "usecredentials".

crimson orchid
#

hmm isn't that a client-side cors thing?

ionic portal
#

Sorry, lol

ionic portal
crimson orchid
#

yeah i'd imagine it'd look something like this - though could you call eden inside a server function? you wouldn't have to mess with any of this stuff

#

eden would need a server-side calling api for that though