Skip to content

Commit 73f57f3

Browse files
committed
fix(@angular/build): proxy karma request from / to /base
This commit fixes an issue where Karma requests were not being correctly proxied, leading to 404 errors for assets and other files during test execution in Angular projects. The fix ensures that all Karma requests from the root (`/`) are correctly forwarded to the `/base` directory, where Karma serves the files. Karma will always serve files from `/base`. This change aligns the testing environment with this fundamental behavior, resolving pathing issues and ensuring that tests can locate their dependencies reliably. Closes angular#30627
1 parent 385635a commit 73f57f3

File tree

1 file changed

+4
-0
lines changed
  • packages/angular/build/src/builders/karma

1 file changed

+4
-0
lines changed

packages/angular/build/src/builders/karma/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,17 @@ function getBuiltInKarmaConfig(
9999
// Any changes to the config here need to be synced to: packages/schematics/angular/config/files/karma.conf.js.template
100100
return {
101101
basePath: '',
102+
rootUrl: '/',
102103
frameworks: ['jasmine'],
103104
plugins: [
104105
'karma-jasmine',
105106
'karma-chrome-launcher',
106107
'karma-jasmine-html-reporter',
107108
'karma-coverage',
108109
].map((p) => workspaceRootRequire(p)),
110+
proxies: {
111+
'/': '/base/',
112+
},
109113
jasmineHtmlReporter: {
110114
suppressAll: true, // removes the duplicated traces
111115
},

0 commit comments

Comments
 (0)