Skip to content

Feito as configuracoes para deixar as APIs ativas no vercel #70

Closed
FenixReloaded wants to merge 11 commits into
developmentfrom
feat/vercel
Closed

Feito as configuracoes para deixar as APIs ativas no vercel #70
FenixReloaded wants to merge 11 commits into
developmentfrom
feat/vercel

Conversation

@FenixReloaded

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI review requested due to automatic review settings December 2, 2025 14:49
@vercel

vercel Bot commented Dec 2, 2025

Copy link
Copy Markdown

Deployment failed with the following error:

The `vercel.json` schema validation failed with the following message: `functions.pages/api/**/*.ts` should NOT have additional property `regions`

Learn More: https://vercel.com/docs/concepts/projects/project-configuration

@vercel

vercel Bot commented Dec 2, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
guia-turistico Error Error Dec 2, 2025 2:49pm

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Comment on lines +5 to +8
// 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

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
// 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'

Copilot uses AI. Check for mistakes.
import type { NextApiRequest, NextApiResponse } from 'next'

export default function health(req: NextApiRequest, res: NextApiResponse) {
const allowedOrigin =

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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'
      : '*';
Suggested change
const allowedOrigin =
const allowedOrigin =

Copilot uses AI. Check for mistakes.
Comment on lines +4 to +8
const allowedOrigin =
process.env.NODE_ENV === 'production'
? process.env.ALLOWED_ORIGIN || 'https://example.com'
: '*';
res.setHeader('Access-Control-Allow-Origin', allowedOrigin);

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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);

Copilot uses AI. Check for mistakes.
Comment on lines +17 to +32
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;
}

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Suggested change
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;
}

Copilot uses AI. Check for mistakes.
Comment thread nextjs-api/vercel.json
"version": 2,
"builds": [
{
"src": "next.config.js",

Copilot AI Dec 2, 2025

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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",
Suggested change
"src": "next.config.js",
"src": "next.config.ts",

Copilot uses AI. Check for mistakes.
@JoaoGW JoaoGW closed this Dec 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants