Skip to content

Commit 3a1f925

Browse files
Giovanni GargiuloGiovanni Gargiulo
authored andcommitted
chore: public api
1 parent 46284d9 commit 3a1f925

File tree

4 files changed

+18
-7
lines changed

4 files changed

+18
-7
lines changed

frontend/.env.development

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
NEXT_PUBLIC_BLOCKFROST_API_KEY=preview63R2hq5OToB1PRYyxDQ1NpmS23rbyS88
22
NETWORK=Preview
3-
NEXT_PUBLIC_API_URL=http://localhost:8080
3+
# Leave empty in development to use Next.js rewrites (proxies to backend)
4+
NEXT_PUBLIC_API_URL=

frontend/.env.production

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
NEXT_PUBLIC_BLOCKFROST_API_KEY=preview63R2hq5OToB1PRYyxDQ1NpmS23rbyS88
22
NETWORK=Preview
3-
NEXT_PUBLIC_API_URL=http://programmable-tokens-int
3+
# Production: Set this to your public API endpoint (e.g., https://api.programmabletokens.xyz)
4+
# This should be the publicly accessible URL for your backend API
5+
NEXT_PUBLIC_API_URL=https://preview-api.programmabletokens.xyz

frontend/next.config.js

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const webpackConfig = (config, { isServer }) => {
3131
};
3232

3333
module.exports = (phase, {defaultConfig}) => {
34+
// Development mode: use Next.js server with rewrites for local API proxy
3435
if (phase === PHASE_DEVELOPMENT_SERVER) {
3536
return {
3637
/* NextJS development-only config options here */
@@ -75,14 +76,16 @@ module.exports = (phase, {defaultConfig}) => {
7576
webpack: webpackConfig
7677
}
7778
}
78-
// Default NextJS config for other phases (e.g., production, static export)
79-
return {
79+
80+
// Production mode: static export (frontend calls API directly using NEXT_PUBLIC_API_URL)
81+
// No rewrites needed as the frontend will call the public API endpoint directly
82+
return {
8083
output: 'export',
8184
webpack: webpackConfig,
8285
experimental: {
8386
esmExternals: true, // Ensure modern module support
8487
},
85-
88+
8689
// https://github.com/Anastasia-Labs/lucid-evolution/issues/437
8790
serverExternalPackages: [
8891
"@lucid-evolution/lucid"

frontend/src/app/clientLayout.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,15 @@ import axios from "axios";
1818
import DemoEnvironmentContext from "./context/demoEnvironmentContext";
1919

2020
async function loadDemoEnvironment(): Promise<DemoEnvironment> {
21-
const response = await axios.get<DemoEnvironment>("/api/v1/demo-environment",
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,
2227
{
2328
headers: {
24-
'Content-Type': 'application/json;charset=utf-8',
29+
'Content-Type': 'application/json;charset=utf-8',
2530
},
2631
});
2732
return response?.data;

0 commit comments

Comments
 (0)