angular-cli icon indicating copy to clipboard operation
angular-cli copied to clipboard

Absolute path usedin --deploy-url caused warning

Open feng-xiao opened this issue 8 years ago • 9 comments

Versions

Angular CLI: 1.6.0
Node: 8.9.1
OS: win32 x64
Angular: 5.1.0
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router, service-worker

@angular/cli: 1.6.0
@angular/platform-server: error
@angular/tsc-wrapped: error
@angular-devkit/build-optimizer: 0.0.35
@angular-devkit/core: 0.0.22
@angular-devkit/schematics: 0.0.41
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.0
@schematics/angular: 0.1.10
@schematics/schematics: 0.0.10
typescript: 2.5.3
webpack: 3.10.0

Repro steps

  • Step 1 Set absolute path (e.g. http://localhost:32323/) to --deploy-url caused warning

Observed behavior

WARNING --deploy-url and/or --base-href contain unsupported values for ng serve.  Default serve path of '/' used. Use --serve-path to override.

Desired behavior

No warning, and the value should be supported

Mention any other details that might be useful (optional)

feng-xiao avatar Dec 12 '17 14:12 feng-xiao

That warning is intentional. The dev server is served using the --host and --port options specified. The dev server path cannot be an absolute path as it is combined with the host and port options to create the full address. As such it defaults to serving from the root of the configured host and port when it cannot calculate the serving path using the deploy URL and base HREF supplied.

Also, for the example path shown above, setting the port to 32323 would allow the application to be accessed from http://localhost:32323/.

clydin avatar Dec 12 '17 15:12 clydin

@clydin Does --host and --port set the concatenated value to webpack_require.p variable?

feng-xiao avatar Dec 12 '17 16:12 feng-xiao

--host, --port, and --serve-path are dev server only settings and have no effect on the built output.

clydin avatar Dec 12 '17 16:12 clydin

@clydin That's why I need to set absolute path on --deploy-url. I came out a solution to integrate Angular CLI project into ASP.NET MVC. In ng serve mode, the application is hosted in IIS Express (assume the port number is 4201), and it's rendering index.html content. I need to also emit scripts and styles that are hosted in dev server (assume port number is 4200) to make automatic build works. Without setting webpack's public path variable, I will get errors as the Angular/Angular CLI think the scripts are hosted in 4201.

I know Angular CLI is hiding many complexities of Webpack, --deploy-url is only parameter I found that can change webpack public path (__webpack_require.p), I don't know why you don't like absolute path set to this parameter

feng-xiao avatar Dec 12 '17 16:12 feng-xiao

If IIS is the client facing server then for development it should be configured to forward the necessary requests to the CLI's dev server. Assuming the application would then be hosted on IIS in some form in production, this would then mimic the production environment.

Also, note that the deploy URL and/or base HREF settings are actually used to generate the application. The dev server just cannot use them to serve the application as explained above.

clydin avatar Dec 12 '17 17:12 clydin

The setting is only for ng serve and hmr mode. I just use dev server to do browser reloading and serving on-the-fly build output. It would be much appreciated if you can support absolute path or shed light for me how to host angular app in ASP.NET MVC and support ng serve

feng-xiao avatar Dec 12 '17 18:12 feng-xiao

To clarify, are you saying it doesn't work when using deploy URL or that you don't want to see the warning?

clydin avatar Dec 12 '17 19:12 clydin

It's working so far. I just don't want to see the warning, and I hope the absolute value won't break other stuff.

feng-xiao avatar Dec 12 '17 20:12 feng-xiao

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.