Skip to content

Options to disable WebDevServer's historyApiFallback #9640

@eib

Description

@eib

Currently, ng serve will serve up the index page whenever an HTTP 404 error would otherwise occur. There are several instances where this is problematic:

  • You've configured the router to use URL fragments (aka "#" hash) and want local development server to mirror production usage -- so that "works on my machine" isn't as possible
  • You're trying to serve a new file and you're not sure if it's being bundled/output/copied successfully. It's frustrating when you try to browse around to find the new file and get index.html contents instead

Repro steps

Observed behavior

Desired behavior

  • I want those 404 Not Found's!

Notes

While it would be fantastic if the cli could inspect the app to determine that the router was configured with { useHash: true}, I'd also be willing to accept a command-line parameter or some new option in .angular-cli.json.

The 404-handling is using WebpackDevServer's .historyApiFallback option.

See also: ./packages/@angular/cli/tasks/serve.ts

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions