Skip to content

Commit 4bf528a

Browse files
committed
fixes
1 parent 6e25dbf commit 4bf528a

2 files changed

Lines changed: 14 additions & 4 deletions

File tree

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,19 @@
1-
import type { RequestHandler } from '@qwik.dev/router';
1+
import { component$ } from '@qwik.dev/core';
2+
import { routeLoader$, type RequestHandler } from '@qwik.dev/router';
3+
4+
// We need a routeLoader$ here to ensure the page is loaded via the loader URL (q-loader-*.json) which triggers the onRequest middleware.
5+
export const useForceLoadingThisIndex = routeLoader$(() => null);
26

37
export const onRequest: RequestHandler<void> = async (onRequestArgs) => {
48
const { redirect, url } = onRequestArgs;
59
throw redirect(302, `${url.pathname}/route/`);
610
};
11+
12+
export default component$(() => {
13+
useForceLoadingThisIndex();
14+
return (
15+
<div id="index">
16+
You should be redirecting to <code>/broken/route</code>
17+
</div>
18+
);
19+
});

e2e/qwik-e2e/tests/qwikrouter/loaders.e2e.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,9 +60,6 @@ test.describe('loaders', () => {
6060
await expect(title).toHaveText('Loaders - Qwik', { useInnerText: true });
6161
await expect(date).toHaveText('date: 2021-01-01T00:00:00.000Z');
6262
await expect(slow).toHaveText('slow: 123');
63-
if (javaScriptEnabled) {
64-
await expect(nestedName).toHaveText('name: stuff');
65-
}
6663
await expect(nestedName).toHaveText('name: welcome');
6764
await expect(nestedDate).toHaveText('date: 2021-01-01T00:00:00.000Z');
6865
await expect(nestedDep).toHaveText('dep: 84');

0 commit comments

Comments
 (0)