update
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
export default function helpers(pterodactyl: any) {
|
||||
return {
|
||||
// helper what return auth header
|
||||
async authHeader() {
|
||||
async authHeader(contentType: string = "application/json") {
|
||||
return {
|
||||
Authorization: `Bearer ${pterodactyl.api_key}`,
|
||||
"Content-Type": "application/json",
|
||||
"Content-Type": contentType,
|
||||
Accept: "Application/vnd.pterodactyl.v1+json",
|
||||
};
|
||||
},
|
||||
@@ -28,5 +28,16 @@ export default function helpers(pterodactyl: any) {
|
||||
async getWorkingDirectory() {
|
||||
return pterodactyl.workingDirectory;
|
||||
},
|
||||
|
||||
// helper that get main site and get csrf token from it
|
||||
async getCsrfToken() {
|
||||
const response = await fetch(`${process.env.NEXT_PUBLIC_URL}`, {
|
||||
method: "GET",
|
||||
});
|
||||
const text = await response.text();
|
||||
const match = text.match(/<meta name="csrf-token" content="(.*)">/);
|
||||
const csrfToken = match ? match[1] : null;
|
||||
return csrfToken;
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user