From 04696f117db020d596134e03d2746017dfc3638e Mon Sep 17 00:00:00 2001 From: Botrel Kilian Date: Thu, 21 Apr 2022 16:15:18 +0200 Subject: [PATCH] fix: __dirname does not exist in ESM --- apps/api/src/express.js | 3 +++ apps/front/vite.config.js | 3 +++ 2 files changed, 6 insertions(+) diff --git a/apps/api/src/express.js b/apps/api/src/express.js index 6dc9067..9ac7ec3 100644 --- a/apps/api/src/express.js +++ b/apps/api/src/express.js @@ -1,5 +1,6 @@ import path from 'node:path' import process from 'node:process' +import { URL } from 'node:url' import bodyParser from 'body-parser' import cuid from 'cuid' @@ -14,6 +15,8 @@ import logRequest from '#src/middleware/log-request.js' import session from '#src/middleware/session.js' import routes from '#src/routes/index.js' +const __dirname = new URL('.', import.meta.url).pathname + const setRequestId = (req, res, next) => { const requestId = cuid() res.set('X-RequestId', requestId) diff --git a/apps/front/vite.config.js b/apps/front/vite.config.js index f3fe0ba..959ed8c 100644 --- a/apps/front/vite.config.js +++ b/apps/front/vite.config.js @@ -1,6 +1,9 @@ import { defineConfig } from 'vite' import vue from '@vitejs/plugin-vue' import path from 'path' +import { URL } from 'node:url' + +const __dirname = new URL('.', import.meta.url).pathname export default defineConfig({ plugins: [vue()],