Tweaked the contents of env variables, read more

NEWS_URI and AUTH_URI had the end of their routes lopped off, so I
could reference /admin using either one of them.
This commit is contained in:
2021-03-14 04:37:35 +11:00
parent c2f1cd76e9
commit 211eb460cb
13 changed files with 23 additions and 23 deletions
+2 -2
View File
@@ -21,7 +21,7 @@ const Account = props => {
//grab the user's info //grab the user's info
useEffect(() => { useEffect(() => {
authTokens.tokenFetch(`${process.env.AUTH_URI}/account`, { authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/account`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Access-Control-Allow-Origin': '*' 'Access-Control-Allow-Origin': '*'
@@ -83,7 +83,7 @@ const update = async (password, retype, contact, tokenFetch) => {
return ['Password is too short']; return ['Password is too short'];
} }
const result = await tokenFetch(`${process.env.AUTH_URI}/update`, { const result = await tokenFetch(`${process.env.AUTH_URI}/auth/account`, {
method: 'PATCH', method: 'PATCH',
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
+1 -1
View File
@@ -6,7 +6,7 @@ const HomePage = props => {
return ( return (
<div className='page'> <div className='page'>
<p>This is the MERN template homepage.</p> <p>This is the MERN template homepage.</p>
<NewsFeed uri={process.env.NEWS_URI} /> <NewsFeed />
</div> </div>
); );
}; };
+1 -1
View File
@@ -66,7 +66,7 @@ const handleSubmit = async (email, password) => {
} }
//send to the auth server //send to the auth server
const result = await fetch(`${process.env.AUTH_URI}/login`, { const result = await fetch(`${process.env.AUTH_URI}/auth/login`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
+1 -1
View File
@@ -82,7 +82,7 @@ const handleSubmit = async (email, username, password, retype, contact) => {
} }
//send to the auth server //send to the auth server
const result = await fetch(`${process.env.AUTH_URI}/signup`, { const result = await fetch(`${process.env.AUTH_URI}/auth/signup`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
+2 -2
View File
@@ -33,7 +33,7 @@ const DeleteAccount = props => {
const handleSubmit = async (password, authTokens) => { const handleSubmit = async (password, authTokens) => {
//schedule a deletion //schedule a deletion
const result = await authTokens.tokenFetch(`${process.env.AUTH_URI}/deletion`, { const result = await authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/account`, {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
@@ -49,7 +49,7 @@ const handleSubmit = async (password, authTokens) => {
} }
//force a logout //force a logout
const result2 = await authTokens.tokenFetch(`${process.env.AUTH_URI}/logout`, { const result2 = await authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/logout`, {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Origin': '*',
+1 -1
View File
@@ -31,7 +31,7 @@ const Member = () => {
{ /* Logout button logs you out of the server too */ } { /* Logout button logs you out of the server too */ }
<Link to='/' onClick={async () => { <Link to='/' onClick={async () => {
const result = await authTokens.tokenFetch(`${process.env.AUTH_URI}/logout`, { //NOTE: this gets overwritten as a bugfix const result = await authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/logout`, { //NOTE: this gets overwritten as a bugfix
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
+4 -4
View File
@@ -18,7 +18,7 @@ const NewsEditor = props => {
//run once //run once
useEffect(async () => { useEffect(async () => {
const result = await fetch(`${process.env.NEWS_URI}/metadata?limit=999`, { const result = await fetch(`${process.env.NEWS_URI}/news/metadata?limit=999`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -46,7 +46,7 @@ const NewsEditor = props => {
//fetch this article //fetch this article
const index = values[0].value; const index = values[0].value;
const result = await fetch(`${process.env.NEWS_URI}/archive/${index}`, { const result = await fetch(`${process.env.NEWS_URI}/news/archive/${index}`, {
headers: { headers: {
'Access-Control-Allow-Origin': '*' 'Access-Control-Allow-Origin': '*'
} }
@@ -119,7 +119,7 @@ const handleSubmit = async (title, author, body, index, tokenFetch) => {
body = body.trim(); body = body.trim();
//fetch POST json data //fetch POST json data
const result = await tokenFetch(`${process.env.NEWS_URI}/${index}`, { const result = await tokenFetch(`${process.env.NEWS_URI}/news/${index}`, {
method: 'PATCH', method: 'PATCH',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -143,7 +143,7 @@ const handleDelete = async (index, tokenFetch) => {
const conf = confirm('Are you sure you want to delete this article?'); const conf = confirm('Are you sure you want to delete this article?');
if (conf) { if (conf) {
const result = await tokenFetch(`${process.env.NEWS_URI}/${index}`, { const result = await tokenFetch(`${process.env.NEWS_URI}/news/${index}`, {
method: 'DELETE' method: 'DELETE'
}); });
+1 -1
View File
@@ -6,7 +6,7 @@ const NewsFeed = props => {
const [articles, setArticles] = useState([]); const [articles, setArticles] = useState([]);
useEffect(async () => { useEffect(async () => {
const result = await fetch(props.uri, { const result = await fetch(`${process.env.NEWS_URI}/news`, {
method: 'GET', method: 'GET',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
+1 -1
View File
@@ -53,7 +53,7 @@ const handleSubmit = async (title, author, body, tokenFetch) => {
//fetch POST json data //fetch POST json data
const result = await tokenFetch( const result = await tokenFetch(
`${process.env.NEWS_URI}`, `${process.env.NEWS_URI}/news`,
{ {
method: 'POST', method: 'POST',
headers: { headers: {
@@ -46,7 +46,7 @@ const PrivilegeEditor = props => {
}; };
const handleSubmit = async (username, privilege, tokenFetch) => { const handleSubmit = async (username, privilege, tokenFetch) => {
const result = await tokenFetch(`${process.env.AUTH_URI}/account/privilege`, { const result = await tokenFetch(`${process.env.AUTH_URI}/admin/privilege`, {
method: 'PATCH', method: 'PATCH',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -28,7 +28,7 @@ const TokenProvider = props => {
if (expired) { if (expired) {
//ping the auth server for a new token //ping the auth server for a new token
const response = await fetch(`${process.env.AUTH_URI}/token`, { const response = await fetch(`${process.env.AUTH_URI}/auth/token`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
@@ -52,8 +52,8 @@ const TokenProvider = props => {
bearer = newAuth.accessToken; bearer = newAuth.accessToken;
//BUGFIX: logging out correctly requires the new refresh token //BUGFIX: logging out correctly requires the new refresh token
if (url == `${process.env.AUTH_URI}/logout`) { if (url == `${process.env.AUTH_URI}/auth/logout`) {
return fetch(`${process.env.AUTH_URI}/logout`, { return fetch(`${process.env.AUTH_URI}/auth/logout`, {
method: 'DELETE', method: 'DELETE',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
+2 -2
View File
@@ -124,8 +124,8 @@ services:
- DB_USERNAME=${projectDBUser} - DB_USERNAME=${projectDBUser}
- DB_PASSWORD=${projectDBPass} - DB_PASSWORD=${projectDBPass}
- DB_TIMEZONE=${dbTimeZone} - DB_TIMEZONE=${dbTimeZone}
- NEWS_URI=https://${newsWebAddress}/news - NEWS_URI=https://${newsWebAddress}
- AUTH_URI=https://${authWebAddress}/auth - AUTH_URI=https://${authWebAddress}
- SECRET_ACCESS=${accessToken} - SECRET_ACCESS=${accessToken}
networks: networks:
- app-network - app-network
+3 -3
View File
@@ -51,9 +51,9 @@ module.exports = ({ production, analyzer }) => {
new DefinePlugin({ new DefinePlugin({
'process.env': { 'process.env': {
'PRODUCTION': production, 'PRODUCTION': production,
'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.eggtrainer.com/news"', 'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.eggtrainer.com"',
'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.eggtrainer.com/auth"', 'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.eggtrainer.com"',
// 'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.eggtrainer.com/chat"', // 'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.eggtrainer.com"',
} }
}), }),
new CleanWebpackPlugin({ new CleanWebpackPlugin({