Hello, I am trying to import a json file in my SSR astro site endpoint.
this works in dev mode:
let gamePostsJsonPath = `../../globals/_gamedata/_${language}_${countryVisitor}.json`;
if (language=='en') {
gamePostsJsonPath = `../../globals/_gamedata/_${language}_${countryVisitor}.json`;
}
// Dynamically import the JSON file
const gamePostsJsonModule = await import(gamePostsJsonPath);
// Access the default export which contains the parsed JSON data
const gamePostsJson = gamePostsJsonModule.default;
// console.log("loaded");
// Assign the JSON data to 'finaltable'
finaltable = gamePostsJson; // 'gamePostsJson' should be an array if the JSON file contains an array
but in production I get a 500 error:
20:26:19 [ERROR] Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/app/dist/server/globals/_gamedata/_en_US.json' imported from /app/dist/server/chunks/pages/builtwith_C83KLSAu.mjs