Skip to content

Commit e9cab67

Browse files
committed
fix(@angular-devkit/build-angular): Internal server error: Invalid URL when using a non localhost IP
When using a non-localhost IP, Vite will correctly populate the `network` property of the `server.resolvedUrls` instead of `local`. Example: ``` ng server --host=127.0.0.2 { local: [], network: [ 'http://127.0.0.2:4200/' ] } ``` Closes angular#27327
1 parent d05f78b commit e9cab67

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

packages/angular_devkit/build_angular/src/tools/vite/angular-memory-plugin.ts

+4-1
Original file line numberDiff line numberDiff line change
@@ -219,9 +219,12 @@ export function createAngularMemoryPlugin(options: AngularMemoryPluginOptions):
219219
}
220220

221221
transformIndexHtmlAndAddHeaders(req.url, rawHtml, res, next, async (html) => {
222+
const resolvedUrls = server.resolvedUrls;
223+
const baseUrl = resolvedUrls?.local[0] ?? resolvedUrls?.network[0];
224+
222225
const { content } = await renderPage({
223226
document: html,
224-
route: new URL(req.originalUrl ?? '/', server.resolvedUrls?.local[0]).toString(),
227+
route: new URL(req.originalUrl ?? '/', baseUrl).toString(),
225228
serverContext: 'ssr',
226229
loadBundle: (uri: string) =>
227230
// eslint-disable-next-line @typescript-eslint/no-explicit-any

0 commit comments

Comments
 (0)