moved to env variables

This commit is contained in:
2024-06-13 15:28:13 +02:00
parent 848ee1ccb4
commit 0704ea59b1
2 changed files with 6 additions and 8 deletions

View File

@@ -1,6 +1,6 @@
import Keycloak from "keycloak-js";
const keycloak = new Keycloak({
url: "https://keycloak.anxietyprime.de/",
url: process.env.REACT_APP_KC,
realm: "Jodel",
clientId: "jodel-frontend",
});

View File

@@ -2,22 +2,20 @@ import axios from "axios"
import {locationUtils} from "../utils/location";
import keycloak from "../Authentification/Keycloak";
const path = "https://api.jodel.anxietyprime.de";
export const postApi = {
async getPostsByCoords (lat, lon) {
if (!keycloak.authenticated) return [];
return (await axios.get(`${path}/posts/${lat}/${lon}`)).data;
return (await axios.get(`${process.env.REACT_APP_API}/posts/${lat}/${lon}`)).data;
},
async getPostByID (id) {
if (!keycloak.authenticated) return [];
return (await axios.get(`${path}/post/${id}`)).data;
return (await axios.get(`${process.env.REACT_APP_API}/post/${id}`)).data;
},
async createNewPost(title, content, parent = null) {
const location = await locationUtils.getCurrentLocation();
if(location.lon && location.lat) {
if(parent !== null) {
await axios.post(`${path}/posts`, {
await axios.post(`${process.env.REACT_APP_API}/posts`, {
"authorID": 1,
"title": title,
"content": content,
@@ -29,7 +27,7 @@ export const postApi = {
"parent": parent
});
} else {
await axios.post(`${path}/posts`, {
await axios.post(`${process.env.REACT_APP_API}/posts`, {
"authorID": 1,
"title": title,
"content": content,
@@ -45,6 +43,6 @@ export const postApi = {
}
},
async reactToPost(id, reaction) {
await axios.patch(`${path}/post/${id}`, {reaction: reaction});
await axios.patch(`${process.env.REACT_APP_API}/post/${id}`, {reaction: reaction});
}
}