diff --git a/client/pages/api/all.ts b/client/pages/api/all.ts index de14fdc..a928623 100644 --- a/client/pages/api/all.ts +++ b/client/pages/api/all.ts @@ -9,7 +9,7 @@ export const config = { maxDuration: 300, } - +// friends feed v1 export default async function handler(req: NextApiRequest, res: NextApiResponse) { console.log("FETCHING FEED") diff --git a/client/pages/api/comment.ts b/client/pages/api/comment.ts index 91d3850..fe89d4f 100644 --- a/client/pages/api/comment.ts +++ b/client/pages/api/comment.ts @@ -1,6 +1,7 @@ import type { NextApiRequest, NextApiResponse } from 'next' import axios from 'axios'; import { getAuthHeaders } from '@/utils/authHeaders'; +import { PROXY } from '@/utils/constants'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { @@ -16,7 +17,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) content: comment, } let options = { - url: "https://mobile.bereal.com/api" + "/content/comments" + "?postId=" + instance_id + "&postUserId=" + poster_user_id, + url: `${PROXY}https://mobile.bereal.com/api` + "/content/comments" + "?postId=" + instance_id + "&postUserId=" + poster_user_id, method: "POST", headers: getAuthHeaders(req.body.token), data: body, diff --git a/client/pages/api/feed.ts b/client/pages/api/feed.ts index 45b6f46..de0a0e5 100644 --- a/client/pages/api/feed.ts +++ b/client/pages/api/feed.ts @@ -9,7 +9,7 @@ export const config = { maxDuration: 300, } - +// deprecated export default async function handler(req: NextApiRequest, res: NextApiResponse) { console.log("FETCING FEED") diff --git a/client/pages/api/friends.ts b/client/pages/api/friends.ts index b505030..31e6e1e 100644 --- a/client/pages/api/friends.ts +++ b/client/pages/api/friends.ts @@ -1,6 +1,7 @@ import type { NextApiRequest, NextApiResponse } from 'next' import axios from 'axios'; import { getAuthHeaders } from '@/utils/authHeaders'; +import { PROXY } from '@/utils/constants'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { let authorization_token = req.body.token; @@ -8,7 +9,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) console.log(authorization_token); return axios.request({ - url: "https://mobile.bereal.com/api" + "/relationships/friends", + url: `${PROXY}https://mobile.bereal.com/api` + "/relationships/friends", method: "GET", headers: getAuthHeaders(req.body.token), }).then( diff --git a/client/pages/api/memories.ts b/client/pages/api/memories.ts index 5f3d41e..b715266 100644 --- a/client/pages/api/memories.ts +++ b/client/pages/api/memories.ts @@ -1,6 +1,7 @@ import type { NextApiRequest, NextApiResponse } from 'next' import axios from 'axios'; import { getAuthHeaders } from '@/utils/authHeaders'; +import { PROXY } from '@/utils/constants'; export const config = { api: { @@ -16,7 +17,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) console.log(authorization_token); return axios.request({ - url: "https://mobile.bereal.com/api" + "/feeds/memories", + url: `${PROXY}https://mobile.bereal.com/api` + "/feeds/memories", method: "GET", headers: getAuthHeaders(req.body.token), }).then( diff --git a/client/pages/api/profile.ts b/client/pages/api/profile.ts index 8f56c9c..28cb15b 100644 --- a/client/pages/api/profile.ts +++ b/client/pages/api/profile.ts @@ -1,6 +1,7 @@ import type { NextApiRequest, NextApiResponse } from 'next' import axios from 'axios'; import { getAuthHeaders } from '@/utils/authHeaders'; +import { PROXY } from '@/utils/constants'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { @@ -10,7 +11,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) console.log(authorization_token, profile_id); return axios.request({ - url: "https://mobile.bereal.com/api" + `/person/profiles/${profile_id}`, + url: `${PROXY}https://mobile.bereal.com/api` + `/person/profiles/${profile_id}`, method: "GET", headers: getAuthHeaders(req.body.token), }).then( diff --git a/client/pages/api/proxy.ts b/client/pages/api/proxy.ts deleted file mode 100644 index b6ff1b3..0000000 --- a/client/pages/api/proxy.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { NextApiRequest, NextApiResponse } from 'next' -import axios from 'axios'; -import { getAuthHeaders } from '@/utils/authHeaders'; - -//testing vercel headers - -export default async function handler(req: NextApiRequest, res: NextApiResponse) { - - let uri = req.query.uri; - - if (!uri) { - res.status(400).json({ status: "error" }); - return; - } - - return axios.request({ - url: uri as string, - method: "GET", - headers: getAuthHeaders(req.body.token), - }).then( - (response) => { - console.log("------------------") - console.log("request success"); - console.log(response.data); - console.log("------------------") - - res.status(200).json(response.data); - } - ).catch( - (error) => { - console.log(error); - res.status(400).json({ status: "error" }); - } - ) -} \ No newline at end of file diff --git a/client/pages/api/react.ts b/client/pages/api/react.ts index 707e6f9..af15abc 100644 --- a/client/pages/api/react.ts +++ b/client/pages/api/react.ts @@ -1,6 +1,7 @@ import type { NextApiRequest, NextApiResponse } from 'next' import axios from 'axios'; import { getAuthHeaders } from '@/utils/authHeaders'; +import { PROXY } from '@/utils/constants'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { @@ -22,7 +23,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) } return axios.request({ - url: "https://mobile.bereal.com/api" + `/content/realmojis`, + url: `${PROXY}https://mobile.bereal.com/api` + `/content/realmojis`, method: "PUT", headers: getAuthHeaders(req.body.token), data: data, diff --git a/client/pages/feed/index.tsx b/client/pages/feed/index.tsx index fc8181c..bde1abf 100644 --- a/client/pages/feed/index.tsx +++ b/client/pages/feed/index.tsx @@ -26,21 +26,20 @@ export default function Feed() { if (!useCheck()) { return <> } - let [ready, setReady] = useState(false); - + let [instances, setInstances] = useState<{ [key: string]: Instance }>({}) let [loading, setLoading] = useState(true); let [failure, setFailure] = useState(""); - let [myinstances, setMyinstances] = useState([]); - useEffect(() => { setLoading(true); let token = localStorage.getItem("token"); let body = JSON.stringify({ "token": token }); - setReady(true); + /* + old feed api + let options = { url: "/api/feed", method: "POST", @@ -48,7 +47,7 @@ export default function Feed() { data: body, } -/* axios.request(options).then( + axios.request(options).then( async (response) => { console.log("response.data") @@ -85,7 +84,8 @@ export default function Feed() { setFailure("SOMETHING WENT WRONG: " + JSON.stringify(error.response.data.error)); setTimeout(() => {setFailure("")}, 5000); } - ) */ + ) + */ let testoptions = { url: "/api/all", @@ -96,20 +96,16 @@ export default function Feed() { axios.request(testoptions).then( async (response) => { + console.log("=====================================") console.log("all feed data") console.log(response.data); console.log("=====================================") let newinstances: { [key: string]: Instance } = {}; async function createInstance(data: any, usr: any) { - /* console.log("CURRENT INSTANCE DATA"); - console.log(data); - console.log("=====================================") */ let id = data.id; let newinstance = await Instance.moment(data, usr); newinstances[id] = newinstance; - /* console.log("newinstances"); - console.log(newinstances); */ setLoading(false); } @@ -235,15 +231,14 @@ export default function Feed() { onClick={closeAds} /> - - ad - ); } return elements; - }) */ + }) + */ + loading ?
: ( Object.keys(instances).length > 0 ?