fix(chatbot-taff): Windows path — process.cwd() → fileURLToPath(import.meta.url)
Crash ESM loader sur Windows (protocole c:) corrigé. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
import { readFileSync } from 'node:fs'
|
||||
import { resolve } from 'node:path'
|
||||
import { fileURLToPath } from 'node:url'
|
||||
import { checkRateLimitJson } from '~/server/utils/rateLimitJson'
|
||||
|
||||
interface PlateformeMinimal {
|
||||
@@ -70,8 +70,8 @@ export default defineEventHandler(async (event) => {
|
||||
// Lire le JSON statique des plateformes
|
||||
let plateformes: PlateformeMinimal[] = []
|
||||
try {
|
||||
const jsonPath = resolve(process.cwd(), 'public/data/plateformes-taff.json')
|
||||
const raw = JSON.parse(readFileSync(jsonPath, 'utf8'))
|
||||
const jsonUrl = new URL('../../public/data/plateformes-taff.json', import.meta.url)
|
||||
const raw = JSON.parse(readFileSync(fileURLToPath(jsonUrl), 'utf8'))
|
||||
plateformes = (raw.plateformes ?? []).map((p: any) => ({
|
||||
id: p.id,
|
||||
nom: p.nom,
|
||||
|
||||
Reference in New Issue
Block a user