fix the constants
This commit is contained in:
parent
3b2a91cf3b
commit
047df7e3d2
1 changed files with 6 additions and 0 deletions
|
|
@ -5,14 +5,20 @@ import { VALIDATED_ENV } from "../../../../lib/constants";
|
||||||
|
|
||||||
export async function GET(request: Request, { params }: { params: { id: string } }) {
|
export async function GET(request: Request, { params }: { params: { id: string } }) {
|
||||||
try {
|
try {
|
||||||
|
console.log(`Fetching news data for id: ${params.id}`);
|
||||||
|
console.log(`API URL: ${VALIDATED_ENV.API_URL}`); // Log the API URL
|
||||||
|
|
||||||
const dataDirectory = path.join(process.cwd(), "public", "data");
|
const dataDirectory = path.join(process.cwd(), "public", "data");
|
||||||
const filePath = path.join(dataDirectory, `${params.id}.json`);
|
const filePath = path.join(dataDirectory, `${params.id}.json`);
|
||||||
const fileContents = await fs.readFile(filePath, "utf8");
|
const fileContents = await fs.readFile(filePath, "utf8");
|
||||||
const newsData = JSON.parse(fileContents);
|
const newsData = JSON.parse(fileContents);
|
||||||
|
|
||||||
|
// You could use VALIDATED_ENV.API_URL here if you needed to make any external API calls
|
||||||
|
|
||||||
return NextResponse.json(newsData);
|
return NextResponse.json(newsData);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error reading news data:", error);
|
console.error("Error reading news data:", error);
|
||||||
|
console.log(`WS URL: ${VALIDATED_ENV.WS_URL}`); // Log the WebSocket URL, just as an example
|
||||||
return NextResponse.json({ error: "News not found" }, { status: 404 });
|
return NextResponse.json({ error: "News not found" }, { status: 404 });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue