ciscoheat / sveltekit-flash-message

Send temporary data after redirect, usually from endpoints. Works with both SSR and client.
https://www.npmjs.com/package/sveltekit-flash-message
MIT License
246 stars 5 forks source link

`redirect` with two parameters does not work with type `Cookies` #34

Closed V-ed closed 3 months ago

V-ed commented 4 months ago

The definition of the redirect with two parameters is as follows : https://github.com/ciscoheat/sveltekit-flash-message/blob/16c68906b9abc435d6d3fccff8fd08cfc928d1aa/src/lib/server.ts#L101-L104

But the implementation only takes in a RequestEvent (as RequestEvent, line 148) :

https://github.com/ciscoheat/sveltekit-flash-message/blob/16c68906b9abc435d6d3fccff8fd08cfc928d1aa/src/lib/server.ts#L143-L150

While I understand that if you don't have the url, you can't properly redirect, this means that using the Cookies type (from event.cookies of course) does not work in the form redirect({hello: 'world'}, event.cookies).


The potential solution would simply to remove the | Cookies from the definition of the 2 args redirect function's arguments type, otherwise I'm not too sure where you'll take the current location from x)

ciscoheat commented 3 months ago

Fixed in 2.4.3