Skip to content
Snippets Groups Projects
Commit 2c953859 authored by yisding's avatar yisding Committed by GitHub
Browse files

Merge pull request #215 from run-llama/seldo/deploy-fixes

parents 1c994ba6 119af438
No related branches found
No related tags found
No related merge requests found
...@@ -88,7 +88,7 @@ export async function createApp({ ...@@ -88,7 +88,7 @@ export async function createApp({
path.join(root, "README.md"), path.join(root, "README.md"),
); );
} else { } else {
await installTemplate({ ...args, backend: true }); await installTemplate({ ...args, backend: true, forBackend: framework });
} }
process.chdir(root); process.chdir(root);
......
...@@ -103,6 +103,7 @@ const installTSTemplate = async ({ ...@@ -103,6 +103,7 @@ const installTSTemplate = async ({
ui, ui,
eslint, eslint,
customApiPath, customApiPath,
forBackend,
}: InstallTemplateArgs) => { }: InstallTemplateArgs) => {
console.log(bold(`Using ${packageManager}.`)); console.log(bold(`Using ${packageManager}.`));
...@@ -120,6 +121,26 @@ const installTSTemplate = async ({ ...@@ -120,6 +121,26 @@ const installTSTemplate = async ({
rename, rename,
}); });
/**
* If the backend is next.js, rename next.config.app.js to next.config.js
* If not, rename next.config.static.js to next.config.js
*/
if (framework == "nextjs" && forBackend === "nextjs") {
const nextConfigAppPath = path.join(root, "next.config.app.js");
const nextConfigPath = path.join(root, "next.config.js");
await fs.rename(nextConfigAppPath, nextConfigPath);
// delete next.config.static.js
const nextConfigStaticPath = path.join(root, "next.config.static.js");
await fs.rm(nextConfigStaticPath);
} else if (framework == "nextjs" && typeof forBackend === "undefined") {
const nextConfigStaticPath = path.join(root, "next.config.static.js");
const nextConfigPath = path.join(root, "next.config.js");
await fs.rename(nextConfigStaticPath, nextConfigPath);
// delete next.config.app.js
const nextConfigAppPath = path.join(root, "next.config.app.js");
await fs.rm(nextConfigAppPath);
}
/** /**
* Copy the selected chat engine files to the target directory and reference it. * Copy the selected chat engine files to the target directory and reference it.
*/ */
......
...@@ -17,4 +17,5 @@ export interface InstallTemplateArgs { ...@@ -17,4 +17,5 @@ export interface InstallTemplateArgs {
eslint: boolean; eslint: boolean;
customApiPath?: string; customApiPath?: string;
openAIKey?: string; openAIKey?: string;
forBackend?: string;
} }
# local env files
.env
...@@ -8,9 +8,21 @@ const port = 8000; ...@@ -8,9 +8,21 @@ const port = 8000;
const env = process.env["NODE_ENV"]; const env = process.env["NODE_ENV"];
const isDevelopment = !env || env === "development"; const isDevelopment = !env || env === "development";
const prodCorsOrigin = process.env["PROD_CORS_ORIGIN"];
if (isDevelopment) { if (isDevelopment) {
console.warn("Running in development mode - allowing CORS for all origins"); console.warn("Running in development mode - allowing CORS for all origins");
app.use(cors()); app.use(cors());
} else if (prodCorsOrigin) {
console.log(
`Running in production mode - allowing CORS for domain: ${prodCorsOrigin}`,
);
const corsOptions = {
origin: prodCorsOrigin, // Restrict to production domain
};
app.use(cors(corsOptions));
} else {
console.warn("Production CORS origin not set, defaulting to no CORS.");
} }
app.use(express.text()); app.use(express.text());
......
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
images: { unoptimized: true },
experimental: {
serverComponentsExternalPackages: ["llamaindex"],
outputFileTracingIncludes: {
"/*": ["./cache/**/*"],
},
},
};
module.exports = nextConfig;
# local env files
.env
...@@ -8,9 +8,21 @@ const port = 8000; ...@@ -8,9 +8,21 @@ const port = 8000;
const env = process.env["NODE_ENV"]; const env = process.env["NODE_ENV"];
const isDevelopment = !env || env === "development"; const isDevelopment = !env || env === "development";
const prodCorsOrigin = process.env["PROD_CORS_ORIGIN"];
if (isDevelopment) { if (isDevelopment) {
console.warn("Running in development mode - allowing CORS for all origins"); console.warn("Running in development mode - allowing CORS for all origins");
app.use(cors()); app.use(cors());
} else if (prodCorsOrigin) {
console.log(
`Running in production mode - allowing CORS for domain: ${prodCorsOrigin}`,
);
const corsOptions = {
origin: prodCorsOrigin, // Restrict to production domain
};
app.use(cors(corsOptions));
} else {
console.warn("Production CORS origin not set, defaulting to no CORS.");
} }
app.use(express.text()); app.use(express.text());
......
/** @type {import('next').NextConfig} */
const nextConfig = {
output: "export",
images: { unoptimized: true },
experimental: {
serverComponentsExternalPackages: ["llamaindex"],
outputFileTracingIncludes: {
"/*": ["./cache/**/*"],
},
},
};
module.exports = nextConfig;
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment