diff --git a/packages/@angular/cli/tasks/serve.ts b/packages/@angular/cli/tasks/serve.ts index e0860ec498e0..c158c83090eb 100644 --- a/packages/@angular/cli/tasks/serve.ts +++ b/packages/@angular/cli/tasks/serve.ts @@ -177,6 +177,8 @@ export default Task.extend({ // set publicPath property to be sent on webpack server config if (serveTaskOptions.deployUrl) { webpackDevServerConfiguration.publicPath = serveTaskOptions.deployUrl; + (webpackDevServerConfiguration.historyApiFallback as any).index = + serveTaskOptions.deployUrl + `/${appConfig.index}`; } if (serveTaskOptions.target === 'production') { diff --git a/tests/e2e/tests/misc/deploy-url.ts b/tests/e2e/tests/misc/deploy-url.ts index 929e982064f8..adb32fef9af2 100644 --- a/tests/e2e/tests/misc/deploy-url.ts +++ b/tests/e2e/tests/misc/deploy-url.ts @@ -1,14 +1,18 @@ import { killAllProcesses } from '../../utils/process'; import { request } from '../../utils/http'; -import { expectToFail } from '../../utils/utils'; import { ngServe } from '../../utils/project'; export default function () { return Promise.resolve() // check when setup through command line arguments - .then(() => ngServe('--deploy-url', '/deployurl', '--base-href', '/deployurl')) - .then(() => expectToFail(() => request('http://localhost:4200'))) - .then(() => request('http://localhost:4200/deployurl')) + .then(() => ngServe('--deploy-url', '/deployurl/', '--base-href', '/deployurl/')) + .then(() => request('http://localhost:4200')) + .then(body => { + if (!body.match(/<\/app-root>/)) { + throw new Error('Response does not match expected value.'); + } + }) + .then(() => request('http://localhost:4200/deployurl/')) .then(body => { if (!body.match(/<\/app-root>/)) { throw new Error('Response does not match expected value.');