Skip to content

Commit

Permalink
por la cresta felipe
Browse files Browse the repository at this point in the history
  • Loading branch information
fforres committed Jul 14, 2020
1 parent d587c40 commit a350d0d
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pages/api/favoritos/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ import { corsMiddleware } from '../../../src/middlewares'

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
await corsMiddleware(req, res)
res.statusCode = 200
try {
const token = req.headers?.[config.authentication.header]
const { id } = decode(token) as { id: string }
res.statusCode = 200
const connection = await dbConnection()
const repository = connection.getRepository(UserEntity)
const user = await repository.findOne({ id })
Expand Down
2 changes: 1 addition & 1 deletion pages/api/login.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { corsMiddleware } from '../../src/middlewares'
import { apiError } from '../../src/apiErrors'

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
await corsMiddleware(req, res)
res.statusCode = 200
if (req.method !== 'POST') {
apiError(res, 'unauthorized method', 401)
return
}
try {
await corsMiddleware(req, res)
const requestPassword = req.body?.password
const email = req.body?.email
if (!requestPassword || !email) {
Expand Down
2 changes: 1 addition & 1 deletion pages/api/signup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ import { corsMiddleware } from '../../src/middlewares'
import { apiError } from '../../src/apiErrors'

const handler = async (req: NextApiRequest, res: NextApiResponse) => {
await corsMiddleware(req, res)
res.statusCode = 200
if (req.method !== 'POST') {
apiError(res, 'unauthorized method', 401)
return
}
try {
await corsMiddleware(req, res)
const password = req.body?.password
const email = req.body?.email
if (!password || !email) {
Expand Down
2 changes: 1 addition & 1 deletion src/middlewares/cors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { runMiddleware } from './helpers'

// Initializing the cors middleware
const cors = Cors({
methods: ['GET', 'HEAD', 'POST', 'OPTIONS'],
methods: ['GET', 'HEAD', 'POST', 'OPTIONS', 'DELETE'],
})

export const corsMiddleware = (req: NextApiRequest, res: NextApiResponse) =>
Expand Down

1 comment on commit a350d0d

@vercel
Copy link

@vercel vercel bot commented on a350d0d Jul 14, 2020

Choose a reason for hiding this comment

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

Please sign in to comment.