Metadata Not Fetching Properly on Vercel (Works in Dev!)

Hi Vercel Community! :wave:

I’ve been stuck on an issue while trying to fetch metadata (like title, description, and images) from Aliexpress product URLs in my serverless functions hosted on Vercel. Here’s the weird part: it works perfectly in my local development environment, but returns blank strings when deployed to Vercel.
I’m using popular libraries like:

These libraries work great for most URLs, and on my local machine, they even return the correct metadata for Aliexpress links. However, once deployed to Vercel, the metadata response becomes incomplete or blank.

Here’s what I get when deployed on Vercel for an Aliexpress link (gets favicon only):

preview:  {
  url: 'https://www.aliexpress.com/item/1005007613200043.html',
  title: '',
  siteName: undefined,
  description: undefined,
  mediaType: 'website',
  contentType: 'text/html',
  images: [],
  videos: [],
  favicons: [ 'https://www.aliexpress.com/favicon.ico' ],
  charset: 'UTF-8'
}

But locally, the response looks like this:

{
  "url": "https://fr.aliexpress.com/item/1005007613200043.html",
  "title": "realme-Smartphone C61, Batterie 5000mAh, Charge SUPERVOOC 15W, Caméra AI 50MP...",
  "description": "Smarter Shopping, Better Living! Aliexpress.com",
  "images": [
    "https://ae01.alicdn.com/kf/S4f8e9c491b8c415387e2b3525570cce2R/realme-Smartphone-C61-Batterie-5000mAh-Charge-SUPERVOOC-15W-Cam-ra-AI.jpg"
  ],
  "siteName": "Aliexpress",
  ...
}

My function :

import type { VercelRequest, VercelResponse } from '@vercel/node'
import { getLinkPreview } from 'link-preview-js';

export const config = {
    regions: ['cdg1'],
  };
export default async function handler(req: VercelRequest, res: VercelResponse) {
  const url = 'https://fr.aliexpress.com/item/1005007096221203.html?gatewayAdapt=glo2fra'
  const preview = await getLinkPreview(url, { followRedirects: "follow", 
    
  },
});
  return res.json({
    message: preview,
  })
}

I feel it is a restriction from Aliexpress, but not sure.

Hi @3aluw, welcome to the Vercel community! Thanks for asking the question here.

I was able to recreate the issue. But, I noticed that preview metadata for other sites such as x.com is working, even on a production deployment on Vercel.

It means that Alibaba has some restrictions on crawling from web servers, which is something we can’t help with.

Thanks for using Vercel. I hope this was helpful.

2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.