fix(torob): sanitize imageLink in Torob API and feed to always use frontend domain and proxy path
This commit is contained in:
1 parent
376fea356f
commit
88060431bb
14 files changed
+9023
-8720
No files matched your search
@@ -1,6 +1,7 @@
|
||||
import { NextRequest, NextResponse } from 'next/server';
|
||||
import { productService } from '../../../../lib/services/productService';
|
||||
import { PRODUCTS } from '../../../../lib/data/products';
|
||||
import { getMediaUrl } from '../../../../lib/media';
|
||||
|
||||
export const dynamic = 'force-dynamic';
|
||||
export const revalidate = 3600;
|
||||
@@ -39,11 +40,13 @@ export async function GET(request: NextRequest) {
|
||||
const nameEn = product.nameEn || '';
|
||||
const title = nameEn ? `${nameFa} (${nameEn})` : nameFa;
|
||||
const primaryImg = product.ogImage || product.image || product.imageUrl || '';
|
||||
const imageLink = primaryImg
|
||||
? primaryImg.startsWith('http')
|
||||
? primaryImg
|
||||
: `${baseUrl}${primaryImg.startsWith('/') ? primaryImg : `/${primaryImg}`}`
|
||||
: '';
|
||||
let imageLink = '';
|
||||
if (primaryImg) {
|
||||
const proxied = getMediaUrl(primaryImg);
|
||||
imageLink = proxied.startsWith('http')
|
||||
? proxied
|
||||
: `${baseUrl}${proxied.startsWith('/') ? proxied : `/${proxied}`}`;
|
||||
}
|
||||
|
||||
const isInStock =
|
||||
product.stockStatus !== 'OUT_OF_STOCK' &&
|
||||
|
||||
Reference in new issue
Block a user