File tree Expand file tree Collapse file tree
apps/sim/app/api/copilot/training Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { createLogger } from '@sim/logger'
22import { type NextRequest , NextResponse } from 'next/server'
33import { z } from 'zod'
4- import {
5- authenticateCopilotRequestSessionOnly ,
6- createUnauthorizedResponse ,
7- } from '@/lib/copilot/request/http'
4+ import { checkInternalApiKey , createUnauthorizedResponse } from '@/lib/copilot/request/http'
85import { env } from '@/lib/core/config/env'
96import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
107
@@ -21,8 +18,8 @@ const TrainingExampleSchema = z.object({
2118} )
2219
2320export const POST = withRouteHandler ( async ( request : NextRequest ) => {
24- const { userId , isAuthenticated } = await authenticateCopilotRequestSessionOnly ( )
25- if ( ! isAuthenticated || ! userId ) {
21+ const auth = checkInternalApiKey ( request )
22+ if ( ! auth . success ) {
2623 return createUnauthorizedResponse ( )
2724 }
2825
Original file line number Diff line number Diff line change 11import { createLogger } from '@sim/logger'
22import { type NextRequest , NextResponse } from 'next/server'
33import { z } from 'zod'
4- import {
5- authenticateCopilotRequestSessionOnly ,
6- createUnauthorizedResponse ,
7- } from '@/lib/copilot/request/http'
4+ import { checkInternalApiKey , createUnauthorizedResponse } from '@/lib/copilot/request/http'
85import { env } from '@/lib/core/config/env'
96import { withRouteHandler } from '@/lib/core/utils/with-route-handler'
107
@@ -27,8 +24,8 @@ const TrainingDataSchema = z.object({
2724} )
2825
2926export const POST = withRouteHandler ( async ( request : NextRequest ) => {
30- const { userId , isAuthenticated } = await authenticateCopilotRequestSessionOnly ( )
31- if ( ! isAuthenticated || ! userId ) {
27+ const auth = checkInternalApiKey ( request )
28+ if ( ! auth . success ) {
3229 return createUnauthorizedResponse ( )
3330 }
3431
You can’t perform that action at this time.
0 commit comments