spotters: fix random 404 on client navigation (random is a page load, not an endpoint shadowed by [slug]); square logo tiles everywhere
Some checks failed
Deploy production / deploy (push) Has been cancelled
Some checks failed
Deploy production / deploy (push) Has been cancelled
This commit is contained in:
11
src/routes/trackers/cars/random/+page.server.ts
Normal file
11
src/routes/trackers/cars/random/+page.server.ts
Normal file
@@ -0,0 +1,11 @@
|
||||
import { redirect } from '@sveltejs/kit';
|
||||
import { randomCar } from '#lib/server/cars.js';
|
||||
import type { PageServerLoad } from './$types';
|
||||
|
||||
// A page load (not a +server.ts endpoint): the client router only knows page routes, so an
|
||||
// endpoint here made client-side navigation fall through to the [brand] page and 404.
|
||||
export const load: PageServerLoad = async ({ setHeaders }) => {
|
||||
const car = await randomCar();
|
||||
setHeaders({ 'cache-control': 'no-store' });
|
||||
redirect(303, car ? `/trackers/cars/${car.brandSlug}/${car.slug}` : '/trackers/cars');
|
||||
};
|
||||
Reference in New Issue
Block a user