From 17b4d887bbb10119a1ec56faa6cba07bc91f53d3 Mon Sep 17 00:00:00 2001 From: Aadhavan Date: Wed, 13 Sep 2023 01:20:07 +0530 Subject: [PATCH] domain change --- lib/global-context.js | 6 +++--- next.config.js | 20 +++++--------------- pages/buy.js | 36 ++++++++++++++++++------------------ pages/leaderboard.js | 2 +- pages/portfolio.js | 2 +- pages/sell.js | 22 +++++++++++----------- pages/transactions.js | 2 +- 7 files changed, 40 insertions(+), 50 deletions(-) diff --git a/lib/global-context.js b/lib/global-context.js index ccc02f4..6e5b50b 100644 --- a/lib/global-context.js +++ b/lib/global-context.js @@ -42,7 +42,7 @@ export function GlobalContextWrapper({ children }) { = sending user info to backend = =============================================*/ const data = { user_email: user.email, user_name: user.displayName } - const apiUrlEndpoint = 'https://mockstock.live/api/user-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/user-lib' const response = await fetch(apiUrlEndpoint, { method: 'POST', body: JSON.stringify({ data }), @@ -59,14 +59,14 @@ export function GlobalContextWrapper({ children }) { function signOut() { localStorage.clear() sessionStorage.clear() - window.location.replace('https://mockstock.live'); + window.location.replace('https://www.mockstock.live'); } /*============================================= = get user info from backend = =============================================*/ async function getUserInfo(data) { - const apiUrlEndpointUser = 'https://mockstock.live/api/get-user-lib' + const apiUrlEndpointUser = 'https://www.mockstock.live/api/get-user-lib' const response = await fetch(apiUrlEndpointUser, { method: 'POST', body: JSON.stringify({ data }), diff --git a/next.config.js b/next.config.js index 8ee0d74..9cf0e39 100644 --- a/next.config.js +++ b/next.config.js @@ -1,17 +1,7 @@ /** @type {import('next').NextConfig} */ - -module.exports = { - async headers() { - return [ - { - source: '/api/:path*', - headers: [ - { key: "Access-Control-Allow-Origin", value: "*" }, - ] - } - ] - } -}, nextConfig = { +const nextConfig = { reactStrictMode: true, - swcMinify: true -}; + swcMinify: true, +} + +module.exports = nextConfig diff --git a/pages/buy.js b/pages/buy.js index aaeab5b..574c044 100644 --- a/pages/buy.js +++ b/pages/buy.js @@ -33,7 +33,7 @@ export default function BuyPage() { /* gets all the stocks from db */ async function getFirstData() { setLoader(true) - const apiUrlEndpoint = 'https://mockstock.live/api/buy-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/buy-lib' const response = await fetch(apiUrlEndpoint) const res = await response.json() setdataResponse(res.products) @@ -97,7 +97,7 @@ export default function BuyPage() { for (let i = 0; i < 51; i += 3) { console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]) - const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib' + const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib' const currResponseYestResult = await fetch(currApiYestUpdate, { method: 'POST', body: JSON.stringify({ @@ -105,7 +105,7 @@ export default function BuyPage() { }), headers: { 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': 'https://mockstock.live/' + 'Access-Control-Allow-Origin': 'https://www.mockstock.live/' }, }) await currResponseYestResult.json() @@ -113,7 +113,7 @@ export default function BuyPage() { for (let i = 51; i < 102; i += 3) { console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]) - const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib' + const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib' const currResponseYestResult = await fetch(currApiYestUpdate, { method: 'POST', body: JSON.stringify({ @@ -121,7 +121,7 @@ export default function BuyPage() { }), headers: { 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': 'https://mockstock.live/' + 'Access-Control-Allow-Origin': 'https://www.mockstock.live/' }, }) await currResponseYestResult.json() @@ -129,7 +129,7 @@ export default function BuyPage() { for (let i = 102; i < 144; i += 3) { // console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]) - const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib' + const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib' const currResponseYestResult = await fetch(currApiYestUpdate, { method: 'POST', body: JSON.stringify({ @@ -137,7 +137,7 @@ export default function BuyPage() { }), headers: { 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': 'https://mockstock.live/' + 'Access-Control-Allow-Origin': 'https://www.mockstock.live/' }, }) await currResponseYestResult.json() @@ -146,13 +146,13 @@ export default function BuyPage() { for (let i = 0; i < 51; i += 3) { // console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]) - const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib' + const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib' const currResponseResult = await fetch(currApiResultUpdate, { method: 'POST', body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }), headers: { 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': 'https://mockstock.live/' + 'Access-Control-Allow-Origin': 'https://www.mockstock.live/' }, }) await currResponseResult.json() @@ -160,13 +160,13 @@ export default function BuyPage() { for (let i = 51; i < 102; i += 3) { // console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]) - const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib' + const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib' const currResponseResult = await fetch(currApiResultUpdate, { method: 'POST', body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }), headers: { 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': 'https://mockstock.live/' + 'Access-Control-Allow-Origin': 'https://www.mockstock.live/' }, }) await currResponseResult.json() @@ -174,19 +174,19 @@ export default function BuyPage() { for (let i = 102; i < 147; i += 3) { // console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]) - const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib' + const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib' const currResponseResult = await fetch(currApiResultUpdate, { method: 'POST', body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }), headers: { 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': 'https://mockstock.live/' + 'Access-Control-Allow-Origin': 'https://www.mockstock.live/' }, }) await currResponseResult.json() } - const apiUrlPercentage = 'https://mockstock.live/api/update-percentage-lib' + const apiUrlPercentage = 'https://www.mockstock.live/api/update-percentage-lib' const responsePercentage = await fetch(apiUrlPercentage) const resPercentage = await responsePercentage.json() setLoader(false) @@ -198,7 +198,7 @@ export default function BuyPage() { useEffect(() => { async function getFirstData() { setLoader(true) - const apiUrlEndpoint = 'https://mockstock.live/api/buy-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/buy-lib' const response = await fetch(apiUrlEndpoint) const res = await response.json() setdataResponse(res.products) @@ -208,17 +208,17 @@ export default function BuyPage() { }, [changed]) const buyStocks = async (data) => { - const apiUrlEndpoint = 'https://mockstock.live/api/buy-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/buy-lib' const response = await fetch(apiUrlEndpoint, { method: 'POST', body: JSON.stringify({ data }), headers: { 'Content-Type': 'application/json', - 'Access-Control-Allow-Origin': 'https://mockstock.live/' + 'Access-Control-Allow-Origin': 'https://www.mockstock.live/' }, }) await response.json() - const apiUpdateBalance = 'https://mockstock.live/api/update-balance-lib' + const apiUpdateBalance = 'https://www.mockstock.live/api/update-balance-lib' const responseBalance = await fetch(apiUpdateBalance) const resBalance = await responseBalance.json() getUserInfo({ user_email: user[0].email }) diff --git a/pages/leaderboard.js b/pages/leaderboard.js index ac2f505..6c498e5 100644 --- a/pages/leaderboard.js +++ b/pages/leaderboard.js @@ -20,7 +20,7 @@ export default function LeaderboardPage() { useEffect(() => { async function getPageData() { setLoader(true) - const apiUrlEndpoint = 'https://mockstock.live/api/leaderboard-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/leaderboard-lib' const response = await fetch(apiUrlEndpoint) const res = await response.json() // console.log(res) diff --git a/pages/portfolio.js b/pages/portfolio.js index e8dd46a..d9bed4a 100644 --- a/pages/portfolio.js +++ b/pages/portfolio.js @@ -24,7 +24,7 @@ export default function PortfolioPage() { async function getPageData() { setLoader(true) const data = { user_email: user[0]?.email, user_emai: user[0]?.email } - const apiUrlEndpoint = 'https://mockstock.live/api/portfolio-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/portfolio-lib' const response = await fetch(apiUrlEndpoint, { method: 'POST', body: JSON.stringify({ data }), diff --git a/pages/sell.js b/pages/sell.js index 2563293..bab5d25 100644 --- a/pages/sell.js +++ b/pages/sell.js @@ -34,7 +34,7 @@ export default function SellPage() { async function getFirstData() { setLoader(true) const data = { user_email: user[0]?.email } - const apiUrlEndpoint = 'https://mockstock.live/api/sell-page-data-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/sell-page-data-lib' const response = await fetch(apiUrlEndpoint, { method: 'POST', body: JSON.stringify({ data }), @@ -105,7 +105,7 @@ export default function SellPage() { for (let i = 0; i < 51; i += 3) { console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]) - const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib' + const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib' const currResponseYestResult = await fetch(currApiYestUpdate, { method: 'POST', body: JSON.stringify({ @@ -121,7 +121,7 @@ export default function SellPage() { for (let i = 51; i < 102; i += 3) { console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]) - const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib' + const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib' const currResponseYestResult = await fetch(currApiYestUpdate, { method: 'POST', body: JSON.stringify({ @@ -137,7 +137,7 @@ export default function SellPage() { for (let i = 102; i < 144; i += 3) { console.log(curr_yest_price[i], curr_yest_price[i + 1], curr_yest_price[i + 2]) - const currApiYestUpdate = 'https://mockstock.live/api/update-yest-lib' + const currApiYestUpdate = 'https://www.mockstock.live/api/update-yest-lib' const currResponseYestResult = await fetch(currApiYestUpdate, { method: 'POST', body: JSON.stringify({ @@ -154,7 +154,7 @@ export default function SellPage() { for (let i = 0; i < 51; i += 3) { console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]) - const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib' + const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib' const currResponseResult = await fetch(currApiResultUpdate, { method: 'POST', body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }), @@ -168,7 +168,7 @@ export default function SellPage() { for (let i = 51; i < 102; i += 3) { console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]) - const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib' + const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib' const currResponseResult = await fetch(currApiResultUpdate, { method: 'POST', body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }), @@ -182,7 +182,7 @@ export default function SellPage() { for (let i = 102; i < 147; i += 3) { console.log(fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]) - const currApiResultUpdate = 'https://mockstock.live/api/update-curr-lib' + const currApiResultUpdate = 'https://www.mockstock.live/api/update-curr-lib' const currResponseResult = await fetch(currApiResultUpdate, { method: 'POST', body: JSON.stringify({ data: [fetchedData[i], fetchedData[i + 1], fetchedData[i + 2]] }), @@ -194,7 +194,7 @@ export default function SellPage() { console.log(currApiResResult) } - const apiUrlPercentage = 'https://mockstock.live/api/update-percentage-lib' + const apiUrlPercentage = 'https://www.mockstock.live/api/update-percentage-lib' const responsePercentage = await fetch(apiUrlPercentage) const resPercentage = await responsePercentage.json() setLoader(false) @@ -208,7 +208,7 @@ export default function SellPage() { async function getFirstData() { setLoader(true) const data = { user_email: user[0]?.email } - const apiUrlEndpoint = 'https://mockstock.live/api/sell-page-data-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/sell-page-data-lib' const response = await fetch(apiUrlEndpoint, { method: 'POST', body: JSON.stringify({ data }), @@ -225,7 +225,7 @@ export default function SellPage() { const sellStocks = async (data) => { console.log(data) - const apiUrlEndpoint = 'https://mockstock.live/api/sell-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/sell-lib' const response = await fetch(apiUrlEndpoint, { method: 'POST', body: JSON.stringify({ data }), @@ -234,7 +234,7 @@ export default function SellPage() { }, }) const res = await response.json() - const apiUpdateBalance = 'https://mockstock.live/api/update-balance-lib' + const apiUpdateBalance = 'https://www.mockstock.live/api/update-balance-lib' const responseBalance = await fetch(apiUpdateBalance) getUserInfo({ user_email: user[0].email }) } diff --git a/pages/transactions.js b/pages/transactions.js index d11b696..da33fb7 100644 --- a/pages/transactions.js +++ b/pages/transactions.js @@ -24,7 +24,7 @@ export default function TansactionsPage() { async function getPageData() { setLoader(true) const data = { user_email: user[0]?.email } - const apiUrlEndpoint = 'https://mockstock.live/api/transactions-lib' + const apiUrlEndpoint = 'https://www.mockstock.live/api/transactions-lib' const response = await fetch(apiUrlEndpoint, { method: 'POST', body: JSON.stringify({ data }),