Fix nucleus API access
diff --git "a/pages/nucleus/transcript/\133code\135/human.js" "b/pages/nucleus/transcript/\133code\135/human.js"
index 89d2370..6af671e 100644
--- "a/pages/nucleus/transcript/\133code\135/human.js"
+++ "b/pages/nucleus/transcript/\133code\135/human.js"
@@ -13,7 +13,7 @@
}
let code;
try {
- code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}?key=${ctx.query.key}&iv=${ctx.query.iv}`))
+ code = (await Axios.get(`${process.env.NUCLEUS_CALLBACK}transcript/${ctx.params.code}?key=${ctx.query.key}&iv=${ctx.query.iv}`))
} catch (e) {
return {
redirect: {
@@ -24,7 +24,7 @@
}
return {
redirect: {
- destination: `http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}?key=${ctx.query.key}&iv=${ctx.query.iv}/human`,
+ destination: `${process.env.NUCLEUS_CALLBACK}transcript/${ctx.params.code}?key=${ctx.query.key}&iv=${ctx.query.iv}/human`,
permanent: true
}
}
diff --git "a/pages/nucleus/transcript/\133code\135/index.js" "b/pages/nucleus/transcript/\133code\135/index.js"
index a08bf0c..3fc2ed6 100644
--- "a/pages/nucleus/transcript/\133code\135/index.js"
+++ "b/pages/nucleus/transcript/\133code\135/index.js"
@@ -27,7 +27,7 @@
for (let i = 0; i < users.length; i++) {
const user = users[i];
const userID = user.replaceAll(/\D/g, '');
- const username = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/users/${userID}`)).data;
+ const username = (await Axios.get(`${process.env.NUCLEUS_CALLBACK}users/${userID}`)).data;
dict["users"][user.replaceAll(/<@|>/g, '')] = username;
}
}
@@ -36,7 +36,7 @@
for (let i = 0; i < channels.length; i++) {
const channel = channels[i];
const channelID = channel.replaceAll(/\D/g, '');
- const channelName = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/channels/${channelID}`)).data;
+ const channelName = (await Axios.get(`${process.env.NUCLEUS_CALLBACK}channels/${channelID}`)).data;
dict["channels"][channel] = channelName;
}
}
@@ -132,32 +132,35 @@
}
}
}
- return {
+ /*return {
redirect: {
destination: `/nucleus/transcript/${ctx.params.code}/human?key=${ctx.query.key}&iv=${ctx.query.iv}`,
permanent: true
}
+ }*/
+ let code;
+ console.log("getting props")
+ try {
+ code = (await Axios.get(`${process.env.NUCLEUS_CALLBACK}transcript/${ctx.params.code}?key=${ctx.query.key}&iv=${ctx.query.iv}`));
+ } catch (e) {
+ console.log(e)
+ console.log(`${process.env.NUCLEUS_CALLBACK}transcript/${ctx.params.code}?key=${ctx.query.key}&iv=${ctx.query.iv}`)
+ return {
+ redirect: {
+ destination: '/nucleus/transcript/invalid',
+ permanent: true
+ }
+ }
}
- // let code;
- // try {
- // code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}?key=${ctx.query.key&iv=${ctx.query.iv}`))
- // } catch (e) {
- // return {
- // redirect: {
- // destination: '/nucleus/transcript/invalid',
- // permanent: true
- // }
- // }
- // }
- // const linkedData = await parse(code.data.messages)
+ const linkedData = await parse(code.data.messages)
- // const channelName = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/channels/${code.data.channel}`)).data;
+ const channelName = (await Axios.get(`${process.env.NUCLEUS_CALLBACK}channels/${code.data.channel}`)).data;
- // return {
- // props: {
- // data: code.data,
- // linkedData,
- // channelName
- // }
- // }
+ return {
+ props: {
+ data: code.data,
+ linkedData,
+ channelName
+ }
+ }
}
diff --git "a/pages/nucleus/transcript/\133code\135/raw.js" "b/pages/nucleus/transcript/\133code\135/raw.js"
index da6ac40..f06c64f 100644
--- "a/pages/nucleus/transcript/\133code\135/raw.js"
+++ "b/pages/nucleus/transcript/\133code\135/raw.js"
@@ -14,7 +14,7 @@
}
let code;
try {
- code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}`))
+ code = (await Axios.get(`${process.env.NUCLEUS_CALLBACK}transcript/${ctx.params.code}`))
} catch (e) {
return {
redirect: {
@@ -25,8 +25,8 @@
}
return {
redirect: {
- destination: `http://${process.env.NUCLEUS_CALLBACK}/transcript/${ctx.params.code}`,
+ destination: `${process.env.NUCLEUS_CALLBACK}transcript/${ctx.params.code}`,
permanent: true
}
}
-}
\ No newline at end of file
+}