mirror of
https://github.com/DI0IK/homepage-plus.git
synced 2025-07-09 14:58:47 +00:00
Infer unifi port, use api widget property for login
This commit is contained in:
parent
fe1064b173
commit
d1b6dad14d
2 changed files with 11 additions and 7 deletions
|
@ -43,12 +43,9 @@ async function getWidget(req) {
|
|||
}
|
||||
|
||||
async function login(widget) {
|
||||
let loginUrl = `${widget.url}/api`;
|
||||
if (widget.prefix === udmpPrefix) {
|
||||
loginUrl += "/auth"
|
||||
}
|
||||
loginUrl += "/login";
|
||||
|
||||
const endpoint = (widget.prefix === udmpPrefix) ? "auth/login" : "login";
|
||||
const api = widgets?.[widget.type]?.api?.replace("{prefix}", ""); // no prefix for login url
|
||||
const loginUrl = new URL(formatApiCall(api, { endpoint, ...widget }));
|
||||
const loginBody = { username: widget.username, password: widget.password, remember: true };
|
||||
const headers = { "Content-Type": "application/json" };
|
||||
const [status, contentType, data, responseHeaders] = await httpProxy(loginUrl, {
|
||||
|
@ -85,6 +82,13 @@ export default async function unifiProxyHandler(req, res) {
|
|||
|
||||
widget.prefix = prefix;
|
||||
|
||||
if (!widget.port) {
|
||||
widget.port = 8443;
|
||||
if (widget.prefix == udmpPrefix) {
|
||||
widget.port = 443
|
||||
}
|
||||
}
|
||||
|
||||
const { endpoint } = req.query;
|
||||
const url = new URL(formatApiCall(api, { endpoint, ...widget }));
|
||||
const params = { method: "GET", headers: {} };
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import unifiProxyHandler from "./proxy";
|
||||
|
||||
const widget = {
|
||||
api: "{url}{prefix}/api/{endpoint}",
|
||||
api: "{url}:{port}{prefix}/api/{endpoint}",
|
||||
proxyHandler: unifiProxyHandler,
|
||||
|
||||
mappings: {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue