使用Windows身份验证的Browsersync

问题描述 投票:10回答:1

我在.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
            }
        }
    });
windows authentication browser-sync
1个回答
0
投票

也许这有效,将请求中的相关标头传递给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();
            }
        }
});
© www.soinside.com 2019 - 2024. All rights reserved.