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
useEffect(() => {
authTokens.tokenFetch(`${process.env.AUTH_URI}/account`, {
authTokens.tokenFetch(`${process.env.AUTH_URI}/auth/account`, {
method: 'GET',
headers: {
'Access-Control-Allow-Origin': '*'
@@ -83,7 +83,7 @@ const update = async (password, retype, contact, tokenFetch) => {
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',
headers: {
'Access-Control-Allow-Origin': '*',
+1 -1
View File
@@ -6,7 +6,7 @@ const HomePage = props => {
return (
<div className='page'>
<p>This is the MERN template homepage.</p>
<NewsFeed uri={process.env.NEWS_URI} />
<NewsFeed />
</div>
);
};
+1 -1
View File
@@ -66,7 +66,7 @@ const handleSubmit = async (email, password) => {
}
//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',
headers: {
'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
const result = await fetch(`${process.env.AUTH_URI}/signup`, {
const result = await fetch(`${process.env.AUTH_URI}/auth/signup`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
+2 -2
View File
@@ -33,7 +33,7 @@ const DeleteAccount = props => {
const handleSubmit = async (password, authTokens) => {
//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',
headers: {
'Access-Control-Allow-Origin': '*',
@@ -49,7 +49,7 @@ const handleSubmit = async (password, authTokens) => {
}
//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',
headers: {
'Access-Control-Allow-Origin': '*',
+1 -1
View File
@@ -31,7 +31,7 @@ const Member = () => {
{ /* Logout button logs you out of the server too */ }
<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',
headers: {
'Content-Type': 'application/json',
+4 -4
View File
@@ -18,7 +18,7 @@ const NewsEditor = props => {
//run once
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',
headers: {
'Content-Type': 'application/json',
@@ -46,7 +46,7 @@ const NewsEditor = props => {
//fetch this article
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: {
'Access-Control-Allow-Origin': '*'
}
@@ -119,7 +119,7 @@ const handleSubmit = async (title, author, body, index, tokenFetch) => {
body = body.trim();
//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',
headers: {
'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?');
if (conf) {
const result = await tokenFetch(`${process.env.NEWS_URI}/${index}`, {
const result = await tokenFetch(`${process.env.NEWS_URI}/news/${index}`, {
method: 'DELETE'
});
+1 -1
View File
@@ -6,7 +6,7 @@ const NewsFeed = props => {
const [articles, setArticles] = useState([]);
useEffect(async () => {
const result = await fetch(props.uri, {
const result = await fetch(`${process.env.NEWS_URI}/news`, {
method: 'GET',
headers: {
'Content-Type': 'application/json',
+1 -1
View File
@@ -53,7 +53,7 @@ const handleSubmit = async (title, author, body, tokenFetch) => {
//fetch POST json data
const result = await tokenFetch(
`${process.env.NEWS_URI}`,
`${process.env.NEWS_URI}/news`,
{
method: 'POST',
headers: {
@@ -46,7 +46,7 @@ const PrivilegeEditor = props => {
};
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',
headers: {
'Content-Type': 'application/json',
@@ -28,7 +28,7 @@ const TokenProvider = props => {
if (expired) {
//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',
headers: {
'Content-Type': 'application/json',
@@ -52,8 +52,8 @@ const TokenProvider = props => {
bearer = newAuth.accessToken;
//BUGFIX: logging out correctly requires the new refresh token
if (url == `${process.env.AUTH_URI}/logout`) {
return fetch(`${process.env.AUTH_URI}/logout`, {
if (url == `${process.env.AUTH_URI}/auth/logout`) {
return fetch(`${process.env.AUTH_URI}/auth/logout`, {
method: 'DELETE',
headers: {
'Content-Type': 'application/json',
+2 -2
View File
@@ -124,8 +124,8 @@ services:
- DB_USERNAME=${projectDBUser}
- DB_PASSWORD=${projectDBPass}
- DB_TIMEZONE=${dbTimeZone}
- NEWS_URI=https://${newsWebAddress}/news
- AUTH_URI=https://${authWebAddress}/auth
- NEWS_URI=https://${newsWebAddress}
- AUTH_URI=https://${authWebAddress}
- SECRET_ACCESS=${accessToken}
networks:
- app-network
+3 -3
View File
@@ -51,9 +51,9 @@ module.exports = ({ production, analyzer }) => {
new DefinePlugin({
'process.env': {
'PRODUCTION': production,
'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.eggtrainer.com/news"',
'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.eggtrainer.com/auth"',
// 'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.eggtrainer.com/chat"',
'NEWS_URI': production ? `"${process.env.NEWS_URI}"` : '"https://dev-news.eggtrainer.com"',
'AUTH_URI': production ? `"${process.env.AUTH_URI}"` : '"https://dev-auth.eggtrainer.com"',
// 'CHAT_URI': production ? `"${process.env.CHAT_URI}"` : '"https://dev-chat.eggtrainer.com"',
}
}),
new CleanWebpackPlugin({