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 { readFileSync } from 'node:fs'
|
||||||
import { resolve } from 'node:path'
|
import { fileURLToPath } from 'node:url'
|
||||||
import { checkRateLimitJson } from '~/server/utils/rateLimitJson'
|
import { checkRateLimitJson } from '~/server/utils/rateLimitJson'
|
||||||
|
|
||||||
interface PlateformeMinimal {
|
interface PlateformeMinimal {
|
||||||
@@ -70,8 +70,8 @@ export default defineEventHandler(async (event) => {
|
|||||||
// Lire le JSON statique des plateformes
|
// Lire le JSON statique des plateformes
|
||||||
let plateformes: PlateformeMinimal[] = []
|
let plateformes: PlateformeMinimal[] = []
|
||||||
try {
|
try {
|
||||||
const jsonPath = resolve(process.cwd(), 'public/data/plateformes-taff.json')
|
const jsonUrl = new URL('../../public/data/plateformes-taff.json', import.meta.url)
|
||||||
const raw = JSON.parse(readFileSync(jsonPath, 'utf8'))
|
const raw = JSON.parse(readFileSync(fileURLToPath(jsonUrl), 'utf8'))
|
||||||
plateformes = (raw.plateformes ?? []).map((p: any) => ({
|
plateformes = (raw.plateformes ?? []).map((p: any) => ({
|
||||||
id: p.id,
|
id: p.id,
|
||||||
nom: p.nom,
|
nom: p.nom,
|
||||||
|
|||||||
Reference in New Issue
Block a user