Skip to content

Commit 3f40ef9

Browse files
committed
chore(api): update api and config references
1 parent 2fb7e0d commit 3f40ef9

File tree

22 files changed

+77
-54
lines changed

22 files changed

+77
-54
lines changed

.env

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
# API Configuration
2+
# Consumed by config/api-origin.js (shares the value across runtime and rewrites)
23
NEXT_PUBLIC_API_URL=http://localhost:8080
4+
# Used in constants/api-config.ts
35
NEXT_PUBLIC_API_REVALIDATION=3600
4-
5-
# CDN Configuration (optional)
6-
NEXT_PUBLIC_CDN_URL=
7-
8-
# Analytics (optional)
9-
NEXT_PUBLIC_ANALYTICS_ID=

.env.example

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# API Configuration
2+
# Consumed by config/api-origin.js (shares the value across runtime and rewrites)
23
NEXT_PUBLIC_API_URL=https://cmnw.me
4+
# Used in constants/api-config.ts
35
NEXT_PUBLIC_API_REVALIDATION=3600
46

57
# CDN Configuration (optional)

app/api/dma/item/[id]/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NextRequest, NextResponse } from "next/server";
22

3-
import { DOMAINS } from "@/constants/domains";
3+
import { ENDPOINTS } from "@/constants/endpoints";
44

55
export async function GET(
66
request: NextRequest,
@@ -16,7 +16,7 @@ export async function GET(
1616
}
1717

1818
try {
19-
const apiUrl = new URL(`${DOMAINS.domain}/api/dma/item`);
19+
const apiUrl = new URL(`${ENDPOINTS.API}/api/dma/item`);
2020

2121
apiUrl.searchParams.set("id", id);
2222

app/api/dma/item/search/route.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
import { NextRequest, NextResponse } from "next/server";
22

3-
const API_BASE_URL =
4-
process.env.NEXT_PUBLIC_API_URL || "https://api.tradewithcmnw.com";
3+
import { API_ORIGIN } from "@/config/api-origin";
4+
5+
const API_BASE_URL = API_ORIGIN;
56

67
export async function GET(request: NextRequest) {
78
const searchParams = request.nextUrl.searchParams;

app/api/osint/character/logs/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NextRequest, NextResponse } from "next/server";
22

3-
import { DOMAINS } from "@/constants/domains";
3+
import { ENDPOINTS } from "@/constants/endpoints";
44

55
export async function GET(request: NextRequest) {
66
const searchParams = request.nextUrl.searchParams;
@@ -14,7 +14,7 @@ export async function GET(request: NextRequest) {
1414
}
1515

1616
try {
17-
const apiUrl = new URL(`${DOMAINS.domain}/api/osint/character/logs`);
17+
const apiUrl = new URL(`${ENDPOINTS.API}/api/osint/character/logs`);
1818

1919
apiUrl.searchParams.set("guid", guid);
2020

app/api/osint/character/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NextRequest, NextResponse } from "next/server";
22

3-
import { DOMAINS } from "@/constants/domains";
3+
import { ENDPOINTS } from "@/constants/endpoints";
44

55
export async function GET(request: NextRequest) {
66
const searchParams = request.nextUrl.searchParams;
@@ -14,7 +14,7 @@ export async function GET(request: NextRequest) {
1414
}
1515

1616
try {
17-
const apiUrl = new URL(`${DOMAINS.domain}/api/osint/character`);
17+
const apiUrl = new URL(`${ENDPOINTS.API}/api/osint/character`);
1818

1919
apiUrl.searchParams.set("guid", guid);
2020

app/api/osint/guild/logs/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NextRequest, NextResponse } from "next/server";
22

3-
import { DOMAINS } from "@/constants/domains";
3+
import { ENDPOINTS } from "@/constants/endpoints";
44

55
export async function GET(request: NextRequest) {
66
const searchParams = request.nextUrl.searchParams;
@@ -14,7 +14,7 @@ export async function GET(request: NextRequest) {
1414
}
1515

1616
try {
17-
const apiUrl = new URL(`${DOMAINS.domain}/api/osint/guild/logs`);
17+
const apiUrl = new URL(`${ENDPOINTS.API}/api/osint/guild/logs`);
1818

1919
apiUrl.searchParams.set("guid", guid);
2020

app/api/osint/guild/route.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { NextRequest, NextResponse } from "next/server";
22

3-
import { DOMAINS } from "@/constants/domains";
3+
import { ENDPOINTS } from "@/constants/endpoints";
44

55
export async function GET(request: NextRequest) {
66
const searchParams = request.nextUrl.searchParams;
@@ -14,7 +14,7 @@ export async function GET(request: NextRequest) {
1414
}
1515

1616
try {
17-
const apiUrl = new URL(`${DOMAINS.domain}/api/osint/guild`);
17+
const apiUrl = new URL(`${ENDPOINTS.API}/api/osint/guild`);
1818

1919
apiUrl.searchParams.set("guid", guid);
2020

app/item/[id]/page.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@ import { MarketHeatmap } from "@/components/item/market-heatmap";
99
import { ItemListing } from "@/components/item/item-listing";
1010
import { ItemContracts } from "@/components/item/item-contracts";
1111
import { generateItemTitle } from "@/lib";
12-
import { DOMAINS } from "@/constants";
12+
import { ENDPOINTS } from "@/constants";
1313

1414
async function getItemData(id: string) {
1515
try {
16-
const res = await fetch(`${DOMAINS.domain}/api/dma/item?id=${id}`, {
16+
const res = await fetch(`${ENDPOINTS.API}/api/dma/item?id=${id}`, {
1717
next: { revalidate: 3600 }, // Revalidate every hour
1818
});
1919

components/character/buttons.tsx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import { Avatar } from "@heroui/react";
44

55
import { Link } from "@/components/custom-link";
6-
import { DOMAINS } from "@/constants";
6+
import { ENDPOINTS } from "@/constants";
77

88
interface CharacterButtonsProps {
99
name: string;
@@ -14,27 +14,27 @@ export const CharacterButtons = ({ name, realm }: CharacterButtonsProps) => {
1414
const services = [
1515
{
1616
name: "WarcraftLogs",
17-
url: `${DOMAINS.warcraftLogs}/character/eu/${realm}/${name}`,
17+
url: `${ENDPOINTS.WARCRAFT_LOGS}/character/eu/${realm}/${name}`,
1818
icon: "/external/wcl.svg",
1919
},
2020
{
2121
name: "RaiderIO",
22-
url: `${DOMAINS.raiderIo}/characters/eu/${realm}/${name}`,
22+
url: `${ENDPOINTS.RAIDER_IO}/characters/eu/${realm}/${name}`,
2323
icon: "/external/rio.svg",
2424
},
2525
{
2626
name: "WoWProgress",
27-
url: `${DOMAINS.wowProgress}/character/eu/${realm}/${name}`,
27+
url: `${ENDPOINTS.WOW_PROGRESS}/character/eu/${realm}/${name}`,
2828
icon: "/external/wp.svg",
2929
},
3030
{
3131
name: "BattleNet",
32-
url: `${DOMAINS.battleNet}/en-gb/character/eu/${realm}/${name}`,
32+
url: `${ENDPOINTS.BATTLE_NET}/en-gb/character/eu/${realm}/${name}`,
3333
icon: "/external/armory.svg",
3434
},
3535
{
3636
name: "Check PvP",
37-
url: `${DOMAINS.checkPvp}/eu/${realm}/${name}`,
37+
url: `${ENDPOINTS.CHECK_PVP}/eu/${realm}/${name}`,
3838
icon: "/external/check-pvp-1.svg",
3939
},
4040
];

0 commit comments

Comments
 (0)