diff --git a/backend/README.md b/backend/README.md index 98c16ce..0690e38 100644 --- a/backend/README.md +++ b/backend/README.md @@ -1,10 +1,4 @@ -# Test Case Manager Backend - -## Technologies - -- Node.js -- Express -- SQLite +# TestPlat Backend ## Install dependencies @@ -12,6 +6,14 @@ npm install ``` +## Set Environmental variable + +Create `.env` File + +``` +NEXT_PUBLIC_BACKEND_ORIGIN=http://localhost:3001 +``` + ## Set up database ```bash diff --git a/backend/index.js b/backend/index.js index fad0031..c6b0b99 100644 --- a/backend/index.js +++ b/backend/index.js @@ -5,8 +5,9 @@ const app = express(); // enable frontend access const cors = require("cors"); +const frontendOrigin = process.env.FRONTEND_ORIGIN || 'http://localhost:3000'; const corsOptions = { - origin: "http://localhost:3000", + origin: frontendOrigin, methods: "GET,HEAD,PUT,PATCH,POST,DELETE", }; app.use(cors(corsOptions)); diff --git a/docs/docs/getstarted/deployment.md b/docs/docs/getstarted/deployment.md new file mode 100644 index 0000000..3b559d7 --- /dev/null +++ b/docs/docs/getstarted/deployment.md @@ -0,0 +1,40 @@ +--- +sidebar_position: 4 +--- + +# Deployment + +## Deploying to Vercel and Render + +Deploy the frontend to Vercel and the backend to Render. + +### Vercel Configuration + +#### Environment Variables + +|key|value| +|-|-| +|NEXT_PUBLIC_BACKEND_ORIGIN|`your backend server origin`| + +#### Settings + +|Settings|value| +|-|-| +|Root Directory|`frontend`| +|Framework Preset|`Next.js`| + +### Render Configuration + +#### Environment Variables + +|key|value| +|-|-| +|FRONTEND_ORIGIN|`your frontend server origin`| + +#### Settings + +|Settings|value| +|-|-| +|Root Directory|`backend`| +|Build Command|`npm ci && npm run migrate && npm run seed`| +|Start Command|`npm run index`| diff --git a/frontend/README.md b/frontend/README.md index 5a7a253..8137674 100644 --- a/frontend/README.md +++ b/frontend/README.md @@ -1,11 +1,4 @@ -# Test Case Manager Frontend - -## Technologies - -- React -- Next.js -- Tailwind CSS -- NextUI +# TestPlat Frontend ## Install dependencies @@ -13,16 +6,16 @@ npm install ``` +## Set Environmental variable + +Create `.env` File + +``` +NEXT_PUBLIC_BACKEND_ORIGIN=http://localhost:3001 +``` + ## Run the development server ```bash npm run dev ``` - -## Edit Environmental variable - -Create `.env` File - -``` -NEXT_PUBLIC_API_SERVER=http://localhost:3001 -``` \ No newline at end of file diff --git a/frontend/config/config.ts b/frontend/config/config.ts index 4fc1c16..abd3be5 100644 --- a/frontend/config/config.ts +++ b/frontend/config/config.ts @@ -1,5 +1,5 @@ const Config = { - apiServer: process.env.NEXT_PUBLIC_API_SERVER || 'http://localhost:3001', + apiServer: process.env.NEXT_PUBLIC_BACKEND_ORIGIN || 'http://localhost:3001', }; export default Config; \ No newline at end of file