diff --git a/libraries/helpers/src/utils/read.or.fetch.ts b/libraries/helpers/src/utils/read.or.fetch.ts index 4ab4e08e..10c93904 100644 --- a/libraries/helpers/src/utils/read.or.fetch.ts +++ b/libraries/helpers/src/utils/read.or.fetch.ts @@ -1,8 +1,8 @@ import {readFileSync} from "fs"; export const readOrFetch = async (path: string) => { - if (path.indexOf('https') === 0) { - return (await fetch(path, {})).arrayBuffer(); + if (path.indexOf('http') === 0) { + return (await fetch(path)).arrayBuffer(); } return readFileSync(path); diff --git a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts index 7c8672f4..6fc8564c 100644 --- a/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts +++ b/libraries/nestjs-libraries/src/database/prisma/posts/posts.service.ts @@ -139,10 +139,12 @@ export class PostsService { settings: JSON.parse(p.settings || '{}'), media: (JSON.parse(p.image || '[]') as Media[]).map((m) => ({ url: - process.env.FRONTEND_URL + - '/' + - process.env.NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY + - m.path, + m.path.indexOf('http') === -1 + ? process.env.FRONTEND_URL + + '/' + + process.env.NEXT_PUBLIC_UPLOAD_STATIC_DIRECTORY + + m.path + : m.path, type: 'image', path: process.env.UPLOAD_DIRECTORY + m.path, })),