feat: fix path

This commit is contained in:
Nevo David 2024-03-14 17:08:13 +07:00
parent 4c60b7794b
commit 96304b91a8
2 changed files with 8 additions and 6 deletions

View File

@ -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);

View File

@ -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,
})),