Replacement Character (�) Display Issue in Japanese Chat After Vercel Deployment

Hello, I am currently developing an AI customer support using the code from openai-assistants-quickstart. The chat works fine in my local environment (npm run dev and npm run build & npm run start), but after deploying it to Vercel, Japanese characters appear as replacement characters (�), as shown in the attached image.

Here are the specific details:

  1. Japanese text displays correctly in the local environment.
  2. After deploying to Vercel, Japanese text is replaced with replacement characters (�).
  3. I followed the deployment steps as instructed in the official repository.

Could anyone provide advice on the cause and solution for this issue? I suspect it might be related to environment settings or encoding issues, but I am not sure of the exact solution. Any help would be greatly appreciated. Thank you!

Edit:
I checked response from https://platform.openai.com/threads/{threadId} and I found the message was generated correctly.

Hi!
Since you have confirmed that the response contains the correct symbols you can try to fix it by manually setting the encoding to UTF-8.

1 Like

Thank you for your reply! You saved me.
I manually set the encoding in the response header and it solved the problem!

Before:

return new Response(stream.toReadableStream());

After:

return new Response(stream.toReadableStream(), {
    headers: {
      "Content-Type": "text/event-stream; charset=utf-8",
    },
  });
1 Like