@@ -108,8 +108,6 @@ Each action receives a `RequestEvent` object, allowing you to read the data with
108
108
``` js
109
109
// @errors: 2304
110
110
// / file: src/routes/#/+page.server.js
111
- import { base } from ' $app/paths' ;
112
-
113
111
/** @type {import('./$types').PageServerLoad} */
114
112
export async function load ({ cookies }) {
115
113
const user = await db .getUserFromSession (cookies .get (' sessionid' ));
@@ -124,7 +122,7 @@ export const actions = {
124
122
const password = data .get (' password' );
125
123
126
124
const user = await db .getUser (email);
127
- cookies .set (' sessionid' , await db .createSession (user), { path: base });
125
+ cookies .set (' sessionid' , await db .createSession (user), { path: ' / ' });
128
126
129
127
return { success: true };
130
128
},
@@ -158,7 +156,6 @@ If the request couldn't be processed because of invalid data, you can return val
158
156
``` diff
159
157
/// file: src/routes/#/+page.server.js
160
158
+ import { fail } from '@sveltejs/kit';
161
- import { base } from '$app/paths';
162
159
163
160
/** @type {import('./$types').Actions} */
164
161
export const actions = {
@@ -177,7 +174,7 @@ export const actions = {
177
174
+ return fail(400, { email, incorrect: true });
178
175
+ }
179
176
180
- cookies.set('sessionid', await db.createSession(user), { path: base });
177
+ cookies.set('sessionid', await db.createSession(user), { path: '/' });
181
178
182
179
return { success: true };
183
180
},
@@ -217,7 +214,6 @@ Redirects (and errors) work exactly the same as in [`load`](load#redirects):
217
214
``` diff
218
215
/// file: src/routes/#/+page.server.js
219
216
+ import { fail, redirect } from '@sveltejs/kit';
220
- import { base } from '$app/paths';
221
217
222
218
/** @type {import('./$types').Actions} */
223
219
export const actions = {
@@ -235,7 +231,7 @@ export const actions = {
235
231
return fail(400, { email, incorrect: true });
236
232
}
237
233
238
- cookies.set('sessionid', await db.createSession(user), { path: base });
234
+ cookies.set('sessionid', await db.createSession(user), { path: '/' });
239
235
240
236
+ if (url.searchParams.has('redirectTo')) {
241
237
+ redirect(303, url.searchParams.get('redirectTo'));
@@ -297,8 +293,6 @@ declare namespace App {
297
293
298
294
// @filename: index.js
299
295
// ---cut---
300
- import { base } from ' $app/paths' ;
301
-
302
296
/** @type {import('./$types').PageServerLoad} */
303
297
export function load (event ) {
304
298
return {
@@ -309,7 +303,7 @@ export function load(event) {
309
303
/** @type {import('./$types').Actions} */
310
304
export const actions = {
311
305
logout: async (event ) => {
312
- event .cookies .delete (' sessionid' , { path: base });
306
+ event .cookies .delete (' sessionid' , { path: ' / ' });
313
307
event .locals .user = null ;
314
308
}
315
309
};
0 commit comments