Fix nucleus API access
diff --git a/.gitignore b/.gitignore
index 74b7586..211d86a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -33,3 +33,5 @@
# vercel
.vercel
+
+.direnv/
diff --git a/Components/Transcripts/Embed.js b/Components/Transcripts/Embed.js
index 43b1ac4..d793b98 100644
--- a/Components/Transcripts/Embed.js
+++ b/Components/Transcripts/Embed.js
@@ -36,7 +36,7 @@
return <Image key={index} src={`https://cdn.discord.com/emojis/${item.replaceAll(/\D/g, '')}`} width={20} height={20} alt="" />
}
if (item.match(user)) {
- const username = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/users/${item.replaceAll(/\D/g, '')}`)).data;
+ const username = (await Axios.get(`${process.env.NUCLEUS_CALLBACK}users/${item.replaceAll(/\D/g, '')}`)).data;
console.log(username)
return <>{username}</>
diff --git a/next.config.js b/next.config.js
index 86c2e9d..4d67c66 100644
--- a/next.config.js
+++ b/next.config.js
@@ -1,3 +1,5 @@
+require('dotenv').config();
+
module.exports = {
reactStrictMode: true,
webpack(config) {
@@ -37,5 +39,8 @@
},
images: {
domains: ["picsum.photos", "cdn.discordapp.com"]
+ },
+ env: {
+ NUCLEUS_CALLBACK: process.env.NUCLEUS_CALLBACK,
}
-};
\ No newline at end of file
+};
diff --git a/package.json b/package.json
index f85ee32..5f9eea4 100644
--- a/package.json
+++ b/package.json
@@ -15,6 +15,7 @@
"@next/bundle-analyzer": "^12.1.6",
"@svgr/webpack": "^5.5.0",
"axios": "^0.21.1",
+ "dotenv": "^16.0.3",
"fs": "^0.0.1-security",
"human-date": "^1.4.0",
"js-cookie": "^3.0.1",
diff --git a/pages/api/nucleus/verify/complete.js b/pages/api/nucleus/verify/complete.js
index 0183270..d8b6a0f 100644
--- a/pages/api/nucleus/verify/complete.js
+++ b/pages/api/nucleus/verify/complete.js
@@ -11,7 +11,7 @@
return res.status(200).send({success: false})
}
try {
- await Axios.post(`http://${process.env.NUCLEUS_CALLBACK}/verify/${req.body.code}`, {
+ await Axios.post(`${process.env.NUCLEUS_CALLBACK}verify/${req.body.code}`, {
secret: process.env.VERIFY_SECRET
});
} catch (e) {
@@ -20,4 +20,4 @@
return res.status(200).send({success: true});
}
-export default Complete;
\ No newline at end of file
+export default Complete;
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
+}
diff --git a/pages/nucleus/verify/index.js b/pages/nucleus/verify/index.js
index 9c84b84..24a0a90 100644
--- a/pages/nucleus/verify/index.js
+++ b/pages/nucleus/verify/index.js
@@ -87,7 +87,7 @@
}
let code;
try {
- code = await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/verify/${ctx.query.code}`);
+ code = await Axios.get(`${process.env.NUCLEUS_CALLBACK}verify/${ctx.query.code}`);
} catch (e) {
return {
redirect: {
@@ -109,4 +109,4 @@
code: ctx.query.code
}
}
-}
\ No newline at end of file
+}
diff --git a/todo/rolemenu/index.js b/todo/rolemenu/index.js
index ca7e493..b233a45 100644
--- a/todo/rolemenu/index.js
+++ b/todo/rolemenu/index.js
@@ -107,7 +107,7 @@
}
let code;
try {
- code = (await Axios.get(`http://${process.env.NUCLEUS_CALLBACK}/rolemenu/${ctx.query.code}`)).data;
+ code = (await Axios.get(`${process.env.NUCLEUS_CALLBACK}rolemenu/${ctx.query.code}`)).data;
} catch (e) {
return {
redirect: {
@@ -128,4 +128,4 @@
headers: headers
}
}
-}
\ No newline at end of file
+}
diff --git a/yarn.lock b/yarn.lock
index dbf855d..9186f3d 100644
--- a/yarn.lock
+++ b/yarn.lock
@@ -3130,6 +3130,11 @@
domelementtype "^2.2.0"
domhandler "^4.2.0"
+dotenv@^16.0.3:
+ version "16.0.3"
+ resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.3.tgz#115aec42bac5053db3c456db30cc243a5a836a07"
+ integrity sha512-7GO6HghkA5fYG9TYnNxi14/7K9f5occMlp3zXAuSxn7CKCxt9xbNWG7yF8hTCSUchlfWSe3uLmlPfigevRItzQ==
+
duplexer@^0.1.2:
version "0.1.2"
resolved "https://registry.yarnpkg.com/duplexer/-/duplexer-0.1.2.tgz#3abe43aef3835f8ae077d136ddce0f276b0400e6"