mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-07 15:53:39 +01:00
FEAT: NGINX Proxy Manager
This commit is contained in:
parent
057d5eca8f
commit
13afe82fa5
@ -2,49 +2,35 @@ import useSWR from "swr";
|
|||||||
|
|
||||||
import Widget from "../widget";
|
import Widget from "../widget";
|
||||||
import Block from "../block";
|
import Block from "../block";
|
||||||
import { useState } from "react";
|
|
||||||
|
|
||||||
export default function Npm({ service }) {
|
export default function Npm({ service }) {
|
||||||
const config = service.widget;
|
const config = service.widget;
|
||||||
const { url } = config;
|
const { url } = config;
|
||||||
|
|
||||||
const [token, setToken] = useState();
|
|
||||||
|
|
||||||
const fetcher = async (reqUrl) => {
|
const fetcher = async (reqUrl) => {
|
||||||
const { url, email, password } = config;
|
const { url, username, password } = config;
|
||||||
const urlConstructed = `${url}/api/tokens`;
|
const loginUrl = `${url}/api/tokens`;
|
||||||
const body = { identity: email, secret: password };
|
const body = { identity: username, secret: password };
|
||||||
|
|
||||||
if (!token) {
|
const res = await fetch(loginUrl, {
|
||||||
const res = await fetch(urlConstructed, {
|
method: "POST",
|
||||||
method: "POST",
|
body: JSON.stringify(body),
|
||||||
body: JSON.stringify(body),
|
headers: {
|
||||||
headers: {
|
"Content-Type": "application/json",
|
||||||
"Content-Type": "application/json",
|
},
|
||||||
},
|
})
|
||||||
})
|
.then((response) => response.json())
|
||||||
.then((response) => response.json())
|
.then(
|
||||||
.then(
|
async (data) =>
|
||||||
async (data) =>
|
await fetch(reqUrl, {
|
||||||
await fetch(reqUrl, {
|
method: "GET",
|
||||||
method: "GET",
|
headers: {
|
||||||
headers: {
|
"Content-Type": "application/json",
|
||||||
"Content-Type": "application/json",
|
Authorization: "Bearer " + data.token,
|
||||||
Authorization: "Bearer " + data.token,
|
},
|
||||||
},
|
})
|
||||||
})
|
);
|
||||||
);
|
return res.json();
|
||||||
return res.json();
|
|
||||||
} else {
|
|
||||||
const resp = await fetch(reqUrl, {
|
|
||||||
method: "GET",
|
|
||||||
headers: {
|
|
||||||
"Content-Type": "application/json",
|
|
||||||
Authorization: "Bearer " + token,
|
|
||||||
},
|
|
||||||
});
|
|
||||||
return resp.json();
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
const { data: infoData, error: infoError } = useSWR(`${url}/api/nginx/proxy-hosts`, fetcher);
|
const { data: infoData, error: infoError } = useSWR(`${url}/api/nginx/proxy-hosts`, fetcher);
|
||||||
|
@ -5,6 +5,11 @@
|
|||||||
- My First Service:
|
- My First Service:
|
||||||
href: http://localhosdt/
|
href: http://localhosdt/
|
||||||
description: Homepage is awesome
|
description: Homepage is awesome
|
||||||
|
widget:
|
||||||
|
type: npm # npm for NGINX Proxy Manager
|
||||||
|
url: http://localhost:81 # no slash at the end
|
||||||
|
username: aidenpwnz@proton.me # your email
|
||||||
|
password: AidenProxy1994! # your password
|
||||||
|
|
||||||
- My Second Group:
|
- My Second Group:
|
||||||
- My Second Service:
|
- My Second Service:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user