Skip to content

Commit 26ecebf

Browse files
smokesumitarora
authored andcommitted
fix(@angular/cli): prefix historyApiFallback.index with deployUrl (#6279)
1 parent 895b759 commit 26ecebf

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

packages/@angular/cli/tasks/serve.ts

+7
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ export default Task.extend({
162162

163163
webpackDevServerConfiguration.hot = serveTaskOptions.hmr;
164164

165+
// set publicPath property to be sent on webpack server config
166+
if (serveTaskOptions.deployUrl) {
167+
webpackDevServerConfiguration.publicPath = serveTaskOptions.deployUrl;
168+
(webpackDevServerConfiguration.historyApiFallback as any).index =
169+
serveTaskOptions.deployUrl + `/${appConfig.index}`;
170+
}
171+
165172
if (serveTaskOptions.target === 'production') {
166173
ui.writeLine(chalk.red(stripIndents`
167174
****************************************************************************************

tests/e2e/tests/misc/deploy-url.ts

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { killAllProcesses } from '../../utils/process';
2+
import { request } from '../../utils/http';
3+
import { ngServe } from '../../utils/project';
4+
5+
export default function () {
6+
return Promise.resolve()
7+
// check when setup through command line arguments
8+
.then(() => ngServe('--deploy-url', '/deployurl/', '--base-href', '/deployurl/'))
9+
.then(() => request('http://localhost:4200'))
10+
.then(body => {
11+
if (!body.match(/<app-root><\/app-root>/)) {
12+
throw new Error('Response does not match expected value.');
13+
}
14+
})
15+
.then(() => request('http://localhost:4200/deployurl/'))
16+
.then(body => {
17+
if (!body.match(/<app-root><\/app-root>/)) {
18+
throw new Error('Response does not match expected value.');
19+
}
20+
})
21+
.then(() => killAllProcesses(), (err) => { killAllProcesses(); throw err; });
22+
}

0 commit comments

Comments
 (0)