使用Windows身份验证的Browsersync

rke*_*ver 10 windows authentication browser-sync

我在.NET应用程序中使用Browsersync.我只使用Windows身份验证设置了iis(禁用匿名身份验证).我得到402.1.当然我可以将匿名设置为启用,它将加载页面,但我将是匿名的,这不是理想的结果.我不太确定在Browsersync中设置哪些选项以使其在Windows身份验证模式下工作.

我正在使用下面的内容并认为它是由于不正确的标题?

browserSync.init({
        proxy: {
            target: 'http://localhost:4300',
            reqHeaders: {
                "host": config.urlObj.host,
                "accept-encoding": "identity",
                "agent": false
            }
        }
    });
Run Code Online (Sandbox Code Playgroud)

lof*_*nki 0

这应该有效。该middleware部分会将原始请求中的相关标头传递给 IIS。

browserSync.init({
        proxy: {
            target: 'http://localhost:4300',
            reqHeaders: {
                "accept-encoding": "identity",
                "agent": false
            },
            middleware: function (req, res, next) {
                if (req.headers.x-logon-user) {
                    res.setHeader("X-Logon-User", req.headers.x-logon-user);
                }
                if (req.headers.authorization) {
                    res.setHeader("Authorization", req.headers.authorization);
                }
                next();
            }
        }
});
Run Code Online (Sandbox Code Playgroud)