Feito as configuracoes para deixar as APIs ativas no vercel #70
Feito as configuracoes para deixar as APIs ativas no vercel #70FenixReloaded wants to merge 11 commits into
Conversation
|
Deployment failed with the following error: Learn More: https://vercel.com/docs/concepts/projects/project-configuration |
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
There was a problem hiding this comment.
Pull request overview
This PR configures the Next.js API to be deployed and active on Vercel, including API endpoint implementations, CORS configuration, and dependency updates.
Key changes:
- Added Vercel deployment configuration with function settings for API routes
- Implemented central API handler with GET/POST endpoints and CORS support
- Updated TypeScript configuration for Node module resolution compatibility
- Disabled SwaggerAccordion component in the main page
Reviewed changes
Copilot reviewed 7 out of 9 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| nextjs-api/vercel.json | Adds Vercel deployment configuration with build settings and serverless function configuration (memory, maxDuration, region) |
| nextjs-api/tsconfig.json | Changes moduleResolution from "bundler" to "node" and adds ignoreDeprecations flag for TypeScript 6.0 compatibility |
| nextjs-api/src/app/page.tsx | Temporarily disables SwaggerAccordion component import and usage |
| nextjs-api/src/api/handler.ts | Implements central API handler with GET/POST method routing and JSON body parsing |
| nextjs-api/pages/api/home.ts | Creates home endpoint with CORS configuration and error handling wrapper |
| nextjs-api/pages/api/health.ts | Adds health check endpoint with environment-based CORS configuration |
| nextjs-api/package-lock.json | Updates Next.js from 15.3.2 to 15.5.6 and sharp image processing library dependencies |
| expo-app/tsconfig.json | Adds ignoreDeprecations flag for TypeScript 6.0 compatibility |
| expo-app/package-lock.json | Updates js-yaml and glob package versions |
Files not reviewed (2)
- expo-app/package-lock.json: Language not supported
- nextjs-api/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Lista de domínios permitidos para CORS (ajuste para seu domínio em produção) | ||
| const allowedOrigins = [ | ||
| 'https://seu-dominio.com', // Substitua pelo seu domínio de produção | ||
| 'http://localhost:3000', // Exemplo para desenvolvimento local |
There was a problem hiding this comment.
The placeholder domain 'https://seu-dominio.com' (Portuguese for "your-domain.com") should be replaced with the actual production domain or removed. This comment indicates it's a placeholder that needs to be updated before production deployment.
| // Lista de domínios permitidos para CORS (ajuste para seu domínio em produção) | |
| const allowedOrigins = [ | |
| 'https://seu-dominio.com', // Substitua pelo seu domínio de produção | |
| 'http://localhost:3000', // Exemplo para desenvolvimento local | |
| // Lista de domínios permitidos para CORS (adicione seu domínio de produção abaixo) | |
| const allowedOrigins = [ | |
| 'http://localhost:3000', // Exemplo para desenvolvimento local | |
| // Adicione aqui seu domínio de produção, por exemplo: 'https://meu-dominio.com' |
| import type { NextApiRequest, NextApiResponse } from 'next' | ||
|
|
||
| export default function health(req: NextApiRequest, res: NextApiResponse) { | ||
| const allowedOrigin = |
There was a problem hiding this comment.
Inconsistent indentation: the variable declaration starts without proper indentation. The const allowedOrigin should be properly indented to match the function body formatting.
Correct formatting:
export default function health(req: NextApiRequest, res: NextApiResponse) {
const allowedOrigin =
process.env.NODE_ENV === 'production'
? process.env.ALLOWED_ORIGIN || 'https://example.com'
: '*';| const allowedOrigin = | |
| const allowedOrigin = |
| const allowedOrigin = | ||
| process.env.NODE_ENV === 'production' | ||
| ? process.env.ALLOWED_ORIGIN || 'https://example.com' | ||
| : '*'; | ||
| res.setHeader('Access-Control-Allow-Origin', allowedOrigin); |
There was a problem hiding this comment.
The placeholder domain 'https://example.com' should be replaced with the actual production domain or a meaningful environment variable. This default fallback could expose the API to unintended origins in production if the environment variable is not set.
| const allowedOrigin = | |
| process.env.NODE_ENV === 'production' | |
| ? process.env.ALLOWED_ORIGIN || 'https://example.com' | |
| : '*'; | |
| res.setHeader('Access-Control-Allow-Origin', allowedOrigin); | |
| let allowedOrigin; | |
| if (process.env.NODE_ENV === 'production') { | |
| if (!process.env.ALLOWED_ORIGIN) { | |
| return res.status(500).json({ | |
| ok: false, | |
| message: 'ALLOWED_ORIGIN environment variable must be set in production', | |
| }); | |
| } | |
| allowedOrigin = process.env.ALLOWED_ORIGIN; | |
| } else { | |
| allowedOrigin = '*'; | |
| } | |
| res.setHeader('Access-Control-Allow-Origin', allowedOrigin); |
| let body; | ||
| if (typeof req.body === 'string') { | ||
| try { | ||
| body = JSON.parse(req.body || '{}'); | ||
| } catch (err) { | ||
|
|
||
| return res.status(400).json({ | ||
| ok: false, | ||
| error: 'Invalid JSON in request body', | ||
| details: err instanceof Error ? err.message : String(err), | ||
| timestamp: Date.now() | ||
| }); | ||
| } | ||
| } else { | ||
| body = req.body; | ||
| } |
There was a problem hiding this comment.
Inconsistent indentation in the handlePost function. Lines 17-32 have 4-space indentation instead of the 2-space indentation used in the rest of the file. This should be corrected for consistency.
| let body; | |
| if (typeof req.body === 'string') { | |
| try { | |
| body = JSON.parse(req.body || '{}'); | |
| } catch (err) { | |
| return res.status(400).json({ | |
| ok: false, | |
| error: 'Invalid JSON in request body', | |
| details: err instanceof Error ? err.message : String(err), | |
| timestamp: Date.now() | |
| }); | |
| } | |
| } else { | |
| body = req.body; | |
| } | |
| let body; | |
| if (typeof req.body === 'string') { | |
| try { | |
| body = JSON.parse(req.body || '{}'); | |
| } catch (err) { | |
| return res.status(400).json({ | |
| ok: false, | |
| error: 'Invalid JSON in request body', | |
| details: err instanceof Error ? err.message : String(err), | |
| timestamp: Date.now() | |
| }); | |
| } | |
| } else { | |
| body = req.body; | |
| } |
| "version": 2, | ||
| "builds": [ | ||
| { | ||
| "src": "next.config.js", |
There was a problem hiding this comment.
The vercel.json references next.config.js, but the actual configuration file is next.config.ts. This mismatch will cause Vercel deployment to fail as it won't find the specified file.
Change line 5 to:
"src": "next.config.ts",| "src": "next.config.js", | |
| "src": "next.config.ts", |
No description provided.