Skip to content

Commit 28ecc89

Browse files
Giovanni GargiuloGiovanni Gargiulo
authored andcommitted
chore: api
1 parent 9a08995 commit 28ecc89

File tree

5 files changed

+456
-438
lines changed

5 files changed

+456
-438
lines changed

frontend/src/app/[username]/index.tsx

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import React, { useContext, useEffect, useState, useMemo } from 'react';
44

55
//Axios imports
66
import axios from 'axios';
7+
import { getApiUrl } from '../utils/apiConfig';
78

89
//Mui imports
910
import { Box, Checkbox, CircularProgress, FormControl, FormControlLabel, InputLabel, MenuItem, Paper, Select, Typography } from '@mui/material';
@@ -356,7 +357,7 @@ export default function Profile() {
356357
};
357358
try {
358359
const response = await axios.post(
359-
'/api/v1/tx/programmable-token/transfer',
360+
getApiUrl('/api/v1/tx/programmable-token/transfer'),
360361
requestData,
361362
{
362363
headers: {
@@ -430,7 +431,7 @@ export default function Profile() {
430431
setIsRegistering(true);
431432
changeAlertInfo({ severity: 'info', message: 'Preparing registration transaction…', open: true, link: '' });
432433
const response = await axios.post(
433-
'/api/v1/tx/programmable-token/register-transfer-scripts',
434+
getApiUrl('/api/v1/tx/programmable-token/register-transfer-scripts'),
434435
{ issuer: issuerAddress },
435436
{ headers: { 'Content-Type': 'application/json;charset=utf-8' } }
436437
);
@@ -484,7 +485,7 @@ export default function Profile() {
484485
setIsInitializingBlacklist(true);
485486
changeAlertInfo({ severity: 'info', message: 'Preparing blacklist initialisation transaction…', open: true, link: '' });
486487
const response = await axios.post(
487-
'/api/v1/tx/programmable-token/blacklist-init',
488+
getApiUrl('/api/v1/tx/programmable-token/blacklist-init'),
488489
{ issuer: issuerAddress },
489490
{ headers: { 'Content-Type': 'application/json;charset=utf-8' } }
490491
);
@@ -572,7 +573,7 @@ export default function Profile() {
572573
};
573574
try {
574575
const response = await axios.post(
575-
'/api/v1/tx/programmable-token/issue',
576+
getApiUrl('/api/v1/tx/programmable-token/issue'),
576577
requestData,
577578
{
578579
headers: {'Content-Type': 'application/json;charset=utf-8'}
@@ -611,7 +612,7 @@ export default function Profile() {
611612
};
612613
try {
613614
const response = await axios.post(
614-
'/api/v1/tx/programmable-token/blacklist',
615+
getApiUrl('/api/v1/tx/programmable-token/blacklist'),
615616
requestData,
616617
{ headers: {'Content-Type': 'application/json;charset=utf-8'} }
617618
);
@@ -657,7 +658,7 @@ export default function Profile() {
657658
};
658659
try {
659660
const response = await axios.post(
660-
'/api/v1/tx/programmable-token/unblacklist',
661+
getApiUrl('/api/v1/tx/programmable-token/unblacklist'),
661662
requestData,
662663
{ headers: {'Content-Type': 'application/json;charset=utf-8'} }
663664
);
@@ -703,7 +704,7 @@ export default function Profile() {
703704
};
704705
try {
705706
const response = await axios.post(
706-
'/api/v1/tx/programmable-token/seize',
707+
getApiUrl('/api/v1/tx/programmable-token/seize'),
707708
requestData,
708709
{ headers: {'Content-Type': 'application/json;charset=utf-8'} }
709710
);

frontend/src/app/clientLayout.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,17 @@ import NavDrawer from './components/NavDrawer';
1010
import { ThemeModeProvider } from "./styles/themeContext";
1111
import "./styles/globals.css";
1212
import { makeLucid, getWalletFromSeed, getProgrammableTokenAddress } from "./utils/walletUtils";
13-
import useStore from './store/store';
13+
import useStore from './store/store';
1414
import WSTAppBar from "./components/WSTAppBar";
1515
import AlertBar from './components/AlertBar';
1616
import { DemoEnvironment, previewEnv } from "./store/types";
1717
import axios from "axios";
1818
import DemoEnvironmentContext from "./context/demoEnvironmentContext";
19+
import { getApiUrl } from "./utils/apiConfig";
1920

2021
async function loadDemoEnvironment(): Promise<DemoEnvironment> {
21-
// In development: use relative URL (will be rewritten by Next.js)
22-
// In production: use NEXT_PUBLIC_API_URL to call API directly
23-
const apiUrl = process.env.NEXT_PUBLIC_API_URL || '';
24-
const endpoint = `${apiUrl}/api/v1/demo-environment`;
25-
26-
const response = await axios.get<DemoEnvironment>(endpoint,
22+
const response = await axios.get<DemoEnvironment>(
23+
getApiUrl('/api/v1/demo-environment'),
2724
{
2825
headers: {
2926
'Content-Type': 'application/json;charset=utf-8',

0 commit comments

Comments
 (0)