Skip to content

overriding/extending devServer properties doesnt work #21

Open

Description

@christianscharr

I am trying to enhance the default CLI configuration of webpack-dev-server. I need to set the following properties:

  • devServer
    • historyApiFallback: true
    • headers

What I am seeing is. that ngw successfully injects this but it seems that @angular/cli overrides it afterwards... It never gets recognized by webpack-dev-server, whatever property I am setting inside "devServer"

Activity

  1. splincode commented on Jul 20, 2018

    @splincode
    Member

    @christianscharr you need usage proxy.conf.js for Angular

    ng serve --proxy-config proxy.conf.js

    const PROXY_CONFIG = {
        "/api/proxy": {
            "target": "http://localhost:3000",
            "secure": false,
            "bypass": function (req, res, proxyOptions) {
                req.headers["X-Custom-Header"] = "yes";
            }
        }
    }
    
    module.exports = PROXY_CONFIG;

    for historyApiFallback you can usage workaround

    1. ng build --watch
    2. run your node server in dist directory (with your history fallback)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedExtra attention is needed

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions