-
Notifications
You must be signed in to change notification settings - Fork 11.9k
fix(@angular/build): simplify SSL handling for ng serve with SSR
#31722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
0b6c271
fix(@angular/build): simplify SSL handling for with SSR
alan-agius4 f2a4b3c
fixup! fix(@angular/build): simplify SSL handling for with SSR
alan-agius4 b5b720d
fixup! fix(@angular/build): simplify SSL handling for with SSR
alan-agius4 6a5fdad
fixup! fix(@angular/build): simplify SSL handling for with SSR
alan-agius4 31a40e2
fixup! fix(@angular/build): simplify SSL handling for with SSR
alan-agius4 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
fix(@angular/build): simplify SSL handling for with SSR
This commit simplifies the handling of self-signed SSL certificates for with SSR. Previously, tests and potentially users had to set or configure to bypass certificate validation issues with self-signed certificates. Closes #31710
- Loading branch information
commit 0b6c271d4dfa4b4b2868393629c58a77210a9b8f
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -169,6 +169,7 @@ | |
| } | ||
| }, | ||
| "resolutions": { | ||
| "typescript": "5.9.3" | ||
| "typescript": "5.9.3", | ||
| "undici-types": "^7.16.0" | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
packages/angular/build/src/tools/vite/plugins/ssr-ssl-plugin.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,64 @@ | ||
| /** | ||
| * @license | ||
| * Copyright Google LLC All Rights Reserved. | ||
| * | ||
| * Use of this source code is governed by an MIT-style license that can be | ||
| * found in the LICENSE file at https://angular.dev/license | ||
| */ | ||
|
|
||
| import type { Plugin } from 'vite'; | ||
|
|
||
| export function createAngularServerSideSSLPlugin(): Plugin { | ||
| return { | ||
| name: 'angular-ssr-ssl-plugin', | ||
| apply: 'serve', | ||
| async configureServer({ config, httpServer }) { | ||
| console.log('config server'); | ||
| const { | ||
| ssr, | ||
| server: { https }, | ||
| } = config; | ||
|
|
||
| if (!ssr || !https) { | ||
| return; | ||
| } | ||
|
|
||
| const { getGlobalDispatcher, setGlobalDispatcher, Agent } = await import('undici'); | ||
| const originalDispatcher = getGlobalDispatcher(); | ||
|
|
||
| setGlobalDispatcher( | ||
| new Agent({ | ||
| connect: { | ||
| ca: [...getCerts(https.key), ...getCerts(https.cert)].join('\n'), | ||
| }, | ||
| }), | ||
| ); | ||
|
|
||
| httpServer?.on('close', () => { | ||
| console.log('setting original'); | ||
| setGlobalDispatcher(originalDispatcher); | ||
| }); | ||
| }, | ||
| }; | ||
| } | ||
|
|
||
| function getCerts( | ||
| items: string | Buffer | (string | Buffer | { pem: string | Buffer })[] | undefined, | ||
| ): string[] { | ||
| if (!items) { | ||
| return []; | ||
| } | ||
|
|
||
| const certs: string[] = []; | ||
| if (Array.isArray(items)) { | ||
| for (const item of items) { | ||
| const value = typeof item === 'string' ? item : item.toString('utf-8'); | ||
| certs.push(value.trim()); | ||
| } | ||
| } else { | ||
| const value = typeof items === 'string' ? items : items.toString('utf-8'); | ||
| certs.push(value.trim()); | ||
| } | ||
|
|
||
| return certs; | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.