fix: me route

This commit is contained in:
Jarrod Flesch
2023-12-19 15:33:09 -05:00
parent d16c710caa
commit af88fb8af4
4 changed files with 4 additions and 6 deletions

View File

@@ -1,3 +1,5 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
/* DO NOT MODIFY it because it could be re-written at any time. */
import { login } from '@payloadcms/next/routes/login'
import config from 'payload-config'

View File

@@ -1,8 +1,6 @@
/* THIS FILE WAS GENERATED AUTOMATICALLY BY PAYLOAD. */
/* DO NOT MODIFY it because it could be re-written at any time. */
import { me } from '@payloadcms/next/routes/me'
import { NextRequest, NextResponse } from 'next/server'
import config from 'payload-config'
export const GET = async (req: NextRequest, res: NextResponse, params: { collection: string }) =>
me({ config, req, res, params })
export const GET = me({ config })

View File

@@ -115,7 +115,7 @@ export const createPayloadRequest = async ({
const req: PayloadRequest = Object.assign(request, customRequest)
req.user = getAuthenticatedUser({
req.user = await getAuthenticatedUser({
payload,
headers: req.headers,
isGraphQL,

View File

@@ -4,14 +4,12 @@ import { createPayloadRequest } from '../createPayloadRequest'
export const me = ({ config }: { config: Promise<SanitizedConfig> }) =>
async function (request: Request, { params }: { params: { collection: string } }) {
console.log('b4 ME')
const req = await createPayloadRequest({ request, config })
const collection = req.payload.collections[params.collection]
const meRes = await meOperation({
collection,
req,
})
console.log('meRes', meRes)
return Response.json(meRes)
}