fix(admin): corrections to sending over to test server for updates
This commit is contained in:
@@ -16,8 +16,7 @@ params:path {
|
|||||||
|
|
||||||
body:json {
|
body:json {
|
||||||
{
|
{
|
||||||
"zipcode": 45247
|
"zipcode": 45245
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,7 @@ router.post("/", async (req: Request, res: Response) => {
|
|||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const loginRes = await axiosInstance.post(
|
const loginRes = (await axiosInstance.post(
|
||||||
`${process.env.MAIN_SERVER}/lst/api/auth/sign-in/username`,
|
`${process.env.MAIN_SERVER}/lst/api/auth/sign-in/username`,
|
||||||
{
|
{
|
||||||
username: process.env.MAIN_SERVER_USERNAME,
|
username: process.env.MAIN_SERVER_USERNAME,
|
||||||
@@ -59,8 +59,8 @@ router.post("/", async (req: Request, res: Response) => {
|
|||||||
{
|
{
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
}
|
}
|
||||||
);
|
)) as any;
|
||||||
const setCookie = loginRes.headers["set-cookie"];
|
const setCookie = loginRes.headers["set-cookie"][0];
|
||||||
|
|
||||||
if (!setCookie) {
|
if (!setCookie) {
|
||||||
throw new Error("Did not receive a Set-Cookie header from login");
|
throw new Error("Did not receive a Set-Cookie header from login");
|
||||||
@@ -73,7 +73,7 @@ router.post("/", async (req: Request, res: Response) => {
|
|||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Cookie: setCookie.join("; "),
|
Cookie: setCookie.split(";")[0],
|
||||||
},
|
},
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,8 +12,8 @@ router.use(
|
|||||||
"/",
|
"/",
|
||||||
requireAuth("user", ["systemAdmin", "admin"]),
|
requireAuth("user", ["systemAdmin", "admin"]),
|
||||||
restrictToHosts([
|
restrictToHosts([
|
||||||
"usmcd1vms036",
|
"usmcd1vms036.alpla.net",
|
||||||
"USMCD1VMS036",
|
"USMCD1VMS036.alpla.net",
|
||||||
"https://usmcd1vms036.alpla.net",
|
"https://usmcd1vms036.alpla.net",
|
||||||
]),
|
]),
|
||||||
addServer
|
addServer
|
||||||
@@ -22,8 +22,8 @@ router.use(
|
|||||||
"/",
|
"/",
|
||||||
requireAuth("user", ["systemAdmin", "admin"]),
|
requireAuth("user", ["systemAdmin", "admin"]),
|
||||||
restrictToHosts([
|
restrictToHosts([
|
||||||
"usmcd1vms036",
|
"usmcd1vms036.alpla.net",
|
||||||
"USMCD1VMS036",
|
"USMCD1VMS036.alpla.net",
|
||||||
"https://usmcd1vms036.alpla.net",
|
"https://usmcd1vms036.alpla.net",
|
||||||
]),
|
]),
|
||||||
updateServer
|
updateServer
|
||||||
|
|||||||
@@ -82,7 +82,7 @@ router.patch("/:token", async (req: Request, res: Response) => {
|
|||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
});
|
});
|
||||||
|
|
||||||
const loginRes = await axiosInstance.post(
|
const loginRes = (await axiosInstance.post(
|
||||||
`${process.env.MAIN_SERVER}/lst/api/auth/sign-in/username`,
|
`${process.env.MAIN_SERVER}/lst/api/auth/sign-in/username`,
|
||||||
{
|
{
|
||||||
username: process.env.MAIN_SERVER_USERNAME,
|
username: process.env.MAIN_SERVER_USERNAME,
|
||||||
@@ -91,8 +91,11 @@ router.patch("/:token", async (req: Request, res: Response) => {
|
|||||||
{
|
{
|
||||||
headers: { "Content-Type": "application/json" },
|
headers: { "Content-Type": "application/json" },
|
||||||
}
|
}
|
||||||
);
|
)) as any;
|
||||||
const setCookie = loginRes.headers["set-cookie"];
|
|
||||||
|
const setCookie = loginRes?.headers["set-cookie"][0];
|
||||||
|
|
||||||
|
//console.log(setCookie.split(";")[0].replace("__Secure-", ""));
|
||||||
|
|
||||||
if (!setCookie) {
|
if (!setCookie) {
|
||||||
throw new Error(
|
throw new Error(
|
||||||
@@ -101,13 +104,13 @@ router.patch("/:token", async (req: Request, res: Response) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const { data, error } = await tryCatch(
|
const { data, error } = await tryCatch(
|
||||||
axios.post(
|
axios.patch(
|
||||||
`${process.env.MAIN_SERVER}/lst/api/admin/server/${token}`,
|
`${process.env.MAIN_SERVER}/lst/api/admin/server/${token}`,
|
||||||
updates,
|
updates,
|
||||||
{
|
{
|
||||||
headers: {
|
headers: {
|
||||||
"Content-Type": "application/json",
|
"Content-Type": "application/json",
|
||||||
Cookie: setCookie.join("; "),
|
Cookie: setCookie.split(";")[0],
|
||||||
},
|
},
|
||||||
withCredentials: true,
|
withCredentials: true,
|
||||||
}
|
}
|
||||||
@@ -115,6 +118,7 @@ router.patch("/:token", async (req: Request, res: Response) => {
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (error) {
|
if (error) {
|
||||||
|
console.log(error);
|
||||||
log.error(
|
log.error(
|
||||||
{ stack: error },
|
{ stack: error },
|
||||||
"There was an error adding the server to Main Server"
|
"There was an error adding the server to Main Server"
|
||||||
|
|||||||
Reference in New Issue
Block a user