# Prismic Preview returns 500 internal error on translated language page

**URL:** <https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657>\
**Category:** Developing with Prismic\
**Tags:** nextjs, typescript\
**Created:** [July 21, 2022, 1:41am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657 "2022-07-21T01:41:30Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrickzsy](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/patrickzsy/32/4199_2.png) [@patrickzsy](https://community.prismic.io/u/patrickzsy)\
**Post date:** [July 21, 2022, 1:41am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/1 "2022-07-21T01:41:30Z")

</div>

Hi everyone,  
I am experiencing this issue where Preview Mode does not work correctly in both production and local when trying to preview a non-english document - it returns a 500 internal error on the preview url. It's working fine on english documents.

And there was an error saying:  
`TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Location"] at ServerResponse.setHeader (_http_outgoing.js:533:3) `

Example of the url after click on preview: [http://localhost:3000/api/preview/?token=https://xxx.prismic.io/previews/Yth8ghEAACcA-Kf1?websitePreviewId=Ys5PKBEAACYAyxzH&documentId=YthH2hEAACkA98HN](http://localhost:3000/api/preview/?token=https://xxx.prismic.io/previews/Yth8ghEAACcA-Kf1?websitePreviewId=Ys5PKBEAACYAyxzH&documentId=YthH2hEAACkA98HN)

My linkResolver function:  
`
export const linkResolver: LinkResolver = doc => {
switch (doc.type) {
case 'course':
return /course/${encodeURIComponent(doc.uid)};
}
}
`

My folder structure under `pages`:  
-- ru  
----[encoded russian folder name]  
------- [slug].tsx  
------- index.tsx  
-- zh  
----[encoded chinese folder name]  
------- [slug].tsx  
------- index.tsx

My package.json:  
"@prismicio/client": "6.6.1",  
"@prismicio/helpers": "2.3.1",  
"@prismicio/next": "0.1.3",  
"@prismicio/react": "2.4.2",

What am I missing here?  
Thanks!

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [July 21, 2022, 11:29am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/3 "2022-07-21T11:29:22Z")

</div>

Hello @patrickzsy

Thanks for reaching out to us.

To debug it, I need more information:

1. How did you implement i18n in the `next.config.js` file?
2. Are you passing locale parameter in `getStaticProps()` function?

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![patrickzsy](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/patrickzsy/32/4199_2.png) [@patrickzsy](https://community.prismic.io/u/patrickzsy)\
**Post date:** [July 22, 2022, 1:04am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/4 "2022-07-22T01:04:51Z")

</div>

Hi @Priyanka,  
Thanks for your reply.  
My next.config.js:

```auto
i18n: { 
    locales: ['en', 'ar', 'de', 'fr', 'es', 'id', 'it', 'nl', 'tr', 'ja', 'pt-br', 'pt-pt', 'zh'],
    localeDetection: false,
    defaultLocale: 'en'
  }

```

I am also passing options: `{lang: ar}` as part of my `getServerSideProps()`. I could access the url by manually input the slug uid but it returns 500 with error `Invalid character in header content ["Location"]` when trying to preview locally and production.

Also I have another question about the how can I access translated document with non-english characters in the url, i.e. [www.example.com/zh/课程收藏/](http://www.example.com/zh/%E8%AF%BE%E7%A8%8B%E6%94%B6%E8%97%8F/). Right now I am putting encoded characters are part of my folder name: `zh/%E8%AF%BE%E7%A8%8B%E6%94%B6%E8%97%8F` but this will stop working as soon as I add `i18n` config as I pasted above in my `next.config.js`.

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [July 22, 2022, 9:44am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/5 "2022-07-22T09:44:18Z")

</div>

Hello @patrickzsy

Have you tried to clear cookies in another language?

---

<div class="post-metadata">

**Author:** ![patrickzsy](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/patrickzsy/32/4199_2.png) [@patrickzsy](https://community.prismic.io/u/patrickzsy)\
**Post date:** [July 25, 2022, 1:46am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/6 "2022-07-25T01:46:36Z")

</div>

Hi @Priyanka , I have tried to clear all the prismic cookie but still returns 500 on the pages which have encoded ascii as part of the url.

---

<div class="post-metadata">

**Author:** ![Priyanka](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/priyanka/32/3223_2.png) [@Priyanka](https://community.prismic.io/u/Priyanka)\
**Post date:** [July 26, 2022, 10:51am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/7 "2022-07-26T10:51:31Z")

</div>

Hello @patrickzsy,

I am unsure what might be causing the issue. I need to dig deeper. For this, I need your project source code. You can send me a private message, though.

Thanks,  
Priyanka

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [August 3, 2022, 10:54pm UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/8 "2022-08-03T22:54:08Z")

</div>

@patrickzsy are you still having this issue? what do you see if you log the alternate\_languages content in your console?

---

<div class="post-metadata">

**Author:** ![patrickzsy](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/patrickzsy/32/4199_2.png) [@patrickzsy](https://community.prismic.io/u/patrickzsy)\
**Post date:** [August 4, 2022, 12:11am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/10 "2022-08-04T00:11:05Z")

</div>

Hi @Pau , Thanks for the reaching out. I am still getting `TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Location"]` when hitting `await redirectToPreviewURL()` in `api/preview.ts`

More details:

```auto
TypeError [ERR_INVALID_CHAR]: Invalid character in header content ["Location"]
    at ServerResponse.setHeader (_http_outgoing.js:533:3)
    at setHeadersFromObject (node_modules/next/dist/compiled/compression/index.js:1:155900)
    at ServerResponse.setWriteHeadHeaders (node_modules/next/dist/compiled/compression/index.js:1:156134)
    at ServerResponse.writeHead (node_modules/next/dist/compiled/compression/index.js:1:155341)
    at redirect (node_modules/next/dist/next-server/server/api-utils.js:27:357)
    at ServerResponse.apiRes.redirect (node_modules/next/dist/next-server/server/api-utils.js:6:354)
    at redirectToPreviewURL (webpack-internal:///../../node_modules/@prismicio/next/dist/index.js:147:16)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
    at async Preview (webpack-internal:///./pages/api/preview.ts:18:3) {
  code: 'ERR_INVALID_CHAR'

```

---

<div class="post-metadata">

**Author:** ![Pau](https://dub1.discourse-cdn.com/flex013/user_avatar/community.prismic.io/pau/32/5422_2.png) [@Pau](https://community.prismic.io/u/Pau)\
**Post date:** [August 5, 2022, 3:51am UTC](https://community.prismic.io/t/prismic-preview-returns-500-internal-error-on-translated-language-page/10657/11 "2022-08-05T03:51:02Z")

</div>

Hey @patrickzsy. From what I can see in different posts online it may be related to a config typo in your setup. It's not related to your repository.

> <https://stackoverflow.com/questions/71342301/posting-message-to-slack-get-typeerror-err-invalid-char-invalid-character-in>
