12 Commits

Author SHA1 Message Date
Alan Agius
10a5b8b6b8 fix(@angular/ssr): disable component bootstrapping during route extraction
This commit disables component bootstrapping during route extraction to prevent invoking the AppComponent and its lifecycle hooks.

Closes #29085
2024-12-11 18:16:46 +01:00
Alan Agius
aed726fca3 fix(@angular/build): add timeout to route extraction
This commit introduces a 30-second timeout for route extraction.
2024-11-27 16:48:33 -05:00
Alan Agius
34574b2906 fix(@angular/ssr): handle nested redirects not explicitly defined in router config
This commit ensures proper handling of nested redirects that are implicitly structured but not explicitly defined in the router configuration.

Closes #28903
2024-11-22 11:10:34 +01:00
Alan Agius
8c534da649 fix(@angular/ssr): handle baseHref that start with ./
Updated function to support handling `baseHref` starting with './' path correctly.
2024-11-21 08:20:58 +01:00
Doug Parker
d3dd8f00d3 fix(@angular/ssr): use wildcard server route configuration on the '/' route when the app router is empty 2024-11-18 10:38:17 -08:00
Alan Agius
b2e2be052f refactor(@angular/ssr): remove RenderMode.AppShell in favor of new configuration option
This commit removes the `RenderMode.AppShell` option. Instead, a new configuration parameter, `{ appShellRoute: 'shell' }`, is introduced to the `provideServerRoutesConfig` method.

```ts
provideServerRoutesConfig(serverRoutes, { appShellRoute: 'shell' })
```
2024-11-08 19:51:35 +01:00
Alan Agius
63722c309c fix(@angular/ssr): ensure wildcard RenderMode is applied when no Angular routes are defined
This fix addresses a bug where, in the absence of defined Angular routes, the RenderMode was not correctly applied based on the wildcard setting.
2024-10-28 16:43:16 +01:00
Alan Agius
64c52521d0 fix(@angular/ssr): show error when multiple routes are set with RenderMode.AppShell
This change introduces error handling to ensure that when multiple routes are configured with `RenderMode.AppShell`, an error message is displayed. This prevents misconfiguration and enhances clarity in route management.
2024-09-26 22:50:37 +02:00
Alan Agius
50df631960 fix(@angular/ssr): improve handling of route mismatches between Angular server routes and Angular router
This commit resolves an issue where routes defined in the Angular server routing configuration did not match those in the Angular router. Previously, discrepancies between these routes went unnoticed by users. With this update, appropriate error messages are now displayed when mismatches occur, enhancing the developer experience and facilitating easier troubleshooting.
2024-09-26 22:50:37 +02:00
Alan Agius
ea4b99b36f refactor(@angular/ssr): add option to exclude fallback SSG routes from extraction
This option allows validation during the build process to ensure that, when the output mode is set to static, no routes requiring server-side rendering are included.
2024-09-17 18:14:56 +02:00
Alan Agius
2640bf7a68 fix(@angular/ssr): correct route extraction and error handling
This commit introduces the following changes:
- Disallows paths starting with a slash to match Angular router behavior.
- Errors are now stored and displayed at a later stage, improving UX by avoiding unnecessary stack traces that are not useful in this context.
2024-09-16 21:22:10 +02:00
Alan Agius
d66aaa3ca4 feat(@angular/ssr): add server routing configuration API
This commit introduces a new server routing configuration API, as discussed in RFC https://github.com/angular/angular/discussions/56785. The new API provides several enhancements:

```ts
const serverRoutes: ServerRoute[] = [
  {
    path: '/error',
    renderMode: RenderMode.Server,
    status: 404,
    headers: {
      'Cache-Control': 'no-cache'
    }
  }
];
```

```ts
const serverRoutes: ServerRoute[] = [
  {
    path: '/product/:id',
    renderMode: RenderMode.Prerender,
    async getPrerenderPaths() {
      const dataService = inject(ProductService);
      const ids = await dataService.getIds(); // Assuming this returns ['1', '2', '3']
      return ids.map(id => ({ id })); // Generates paths like: [{ id: '1' }, { id: '2' }, { id: '3' }]
    }
  }
];
```

```ts
const serverRoutes: ServerRoute[] = [
  {
    path: '/product/:id',
    renderMode: RenderMode.Prerender,
    fallback: PrerenderFallback.Server, // Can be Server, Client, or None
    async getPrerenderPaths() {
    }
  }
];
```

```ts
const serverRoutes: ServerRoute[] = [
  {
    path: '/product/:id',
    renderMode: RenderMode.Server,
  },
  {
    path: '/error',
    renderMode: RenderMode.Client,
  },
  {
    path: '/**',
    renderMode: RenderMode.Prerender,
  },
];
```

These additions aim to provide greater flexibility and control over server-side rendering configurations and prerendering behaviors.
2024-09-12 19:59:05 +02:00