[英]Basic auth with Cors using express
所以我試圖將離子應用程序與當前的工作系統集成。 我有一個 api 處理程序來使用 express 解決 cors/cross origin。
目前我的標題 api 是:
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "http://localhost:4200");
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
res.header(
"Access-Control-Allow-Headers",
"Authorization, Origin, X-Requested-With, Content-Type, Accept"
);
res.header("Access-Control-Allow-Credentials", "true");
res.header('Authorization', auth);
next();
});
它到達這個 url 並提示用戶是這樣的,這是幕后的 hta 訪問文件用戶提示
我想我需要讓我的 api 發送 header 這恰好是基本身份驗證:
var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
現在我的問題是如何在獲取之前處理此提示/登錄?
I tried passing the Auth in the res.header which sends an outgoing header object that looks like this Header object
所以我試圖將離子應用程序與當前的工作系統集成。 我有一個 api 處理程序來使用 express 解決 cors/cross origin。
目前我的標題 api 是:
app.use((req, res, next) => {
res.header("Access-Control-Allow-Origin", "http://localhost:4200");
res.header("Access-Control-Allow-Methods", "GET, POST, OPTIONS");
res.header(
"Access-Control-Allow-Headers",
"Authorization, Origin, X-Requested-With, Content-Type, Accept"
);
res.header("Access-Control-Allow-Credentials", "true");
res.header('Authorization', auth);
next();
});
它到達這個 url 並提示用戶是這樣的,這是幕后的 hta 訪問文件用戶提示
我想我需要讓我的 api 發送 header 這恰好是基本身份驗證:
var auth = 'Basic ' + Buffer.from(username + ':' + password).toString('base64');
現在我的問題是如何在獲取之前處理此提示/登錄?
I tried passing the Auth in the res.header which sends an outgoing header object that looks like this Header object
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.