serwist static assets missing #21877

Open
opened 2026-02-21 20:14:41 -05:00 by yindo · 7 comments
Owner

Originally created by @jingsam on GitHub (Jan 24, 2026).

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

1.11.4

Cloud or Self Hosted

Self Hosted (Docker)

Steps to reproduce

Open a chatbot app in the new tab, inspect the page with Chrome Devtools. I noticed that all serwist related assets were reponsed with 404.

For example, https://dify.foxgis.com/serwist/logo/logo.svg is not found. Wheras https://dify.foxgis.com/ogo/logo.svg does exist.

Image

✔️ Expected Behavior

no 404

Actual Behavior

Can't reponse with correct assets.

Originally created by @jingsam on GitHub (Jan 24, 2026). ### Self Checks - [x] I have read the [Contributing Guide](https://github.com/langgenius/dify/blob/main/CONTRIBUTING.md) and [Language Policy](https://github.com/langgenius/dify/issues/1542). - [x] This is only for bug report, if you would like to ask a question, please head to [Discussions](https://github.com/langgenius/dify/discussions/categories/general). - [x] I have searched for existing issues [search for existing issues](https://github.com/langgenius/dify/issues), including closed ones. - [x] I confirm that I am using English to submit this report, otherwise it will be closed. - [x] 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :) - [x] Please do not modify this template :) and fill in all the required fields. ### Dify version 1.11.4 ### Cloud or Self Hosted Self Hosted (Docker) ### Steps to reproduce Open a chatbot app in the new tab, inspect the page with Chrome Devtools. I noticed that all serwist related assets were reponsed with 404. For example, https://dify.foxgis.com/serwist/logo/logo.svg is not found. Wheras https://dify.foxgis.com/ogo/logo.svg does exist. <img width="2880" height="1558" alt="Image" src="https://github.com/user-attachments/assets/e3960b13-a4cf-464c-abd2-bb4d214c081d" /> ### ✔️ Expected Behavior no 404 ### ❌ Actual Behavior Can't reponse with correct assets.
yindo added the 🐞 bug label 2026-02-21 20:14:41 -05:00
Author
Owner

@dosubot[bot] commented on GitHub (Jan 24, 2026):

The 404 errors for assets under /serwist/ are likely because these files aren't being generated or included in the service worker's precache manifest during build. In Dify, assets like /ogo/logo.svg are served directly from the public directory, but /serwist/ assets rely on the service worker and its manifest, which is built using the Serwist tooling and Next.js app router. If the files aren't present in the build output or aren't referenced in the manifest, requests will 404 (source).

Check that the assets you expect under /serwist/ actually exist in your source directories before building. Also, make sure your Docker build sets the NEXT_PUBLIC_BASE_PATH environment variable correctly, as recent changes allow this to be set dynamically and it affects asset routing (source). If the assets are missing from the build output or not referenced in the manifest, add them to the appropriate source directory and rebuild.

If you need to verify, inspect the build output for the presence of /serwist/logo/logo.svg and check that the service worker manifest includes it. If not, update your build config or asset locations so these files are picked up and precached.

To reply, just mention @dosu.


How did I do? Good | Irrelevant | Incorrect | Verbose | Hallucination | Report 🐛 | Other

Chat with Dosu Open in Cursor Join Discord Share on X

@dosubot[bot] commented on GitHub (Jan 24, 2026): <!-- Answer --> The 404 errors for assets under `/serwist/` are likely because these files aren't being generated or included in the service worker's precache manifest during build. In Dify, assets like `/ogo/logo.svg` are served directly from the `public` directory, but `/serwist/` assets rely on the service worker and its manifest, which is built using the Serwist tooling and Next.js app router. If the files aren't present in the build output or aren't referenced in the manifest, requests will 404 ([source](https://github.com/langgenius/dify/blob/9d38af6d99d6a2f2b64004895d154ae5d59ca64d/web/app/sw.ts#L5-L105)). Check that the assets you expect under `/serwist/` actually exist in your source directories before building. Also, make sure your Docker build sets the `NEXT_PUBLIC_BASE_PATH` environment variable correctly, as recent changes allow this to be set dynamically and it affects asset routing ([source](https://github.com/langgenius/dify/pull/29836)). If the assets are missing from the build output or not referenced in the manifest, add them to the appropriate source directory and rebuild. If you need to verify, inspect the build output for the presence of `/serwist/logo/logo.svg` and check that the service worker manifest includes it. If not, update your build config or asset locations so these files are picked up and precached. <!-- Dosu Comment Footer --> *To reply, just mention [@dosu](https://go.dosu.dev/dosubot).* --- <sup>How did I do? [Good](https://app.dosu.dev/response-feedback/07d5fbdd-b346-40b7-8f3a-3fcafb50da5c?feedback_type=great_response) | [Irrelevant](https://app.dosu.dev/response-feedback/07d5fbdd-b346-40b7-8f3a-3fcafb50da5c?feedback_type=irrelevant_answer) | [Incorrect](https://app.dosu.dev/response-feedback/07d5fbdd-b346-40b7-8f3a-3fcafb50da5c?feedback_type=incorrect_sources) | [Verbose](https://app.dosu.dev/response-feedback/07d5fbdd-b346-40b7-8f3a-3fcafb50da5c?feedback_type=too_verbose) | [Hallucination](https://app.dosu.dev/response-feedback/07d5fbdd-b346-40b7-8f3a-3fcafb50da5c?feedback_type=hallucination) | [Report 🐛](https://app.dosu.dev/response-feedback/07d5fbdd-b346-40b7-8f3a-3fcafb50da5c?feedback_type=bug_report) | [Other](https://app.dosu.dev/response-feedback/07d5fbdd-b346-40b7-8f3a-3fcafb50da5c?feedback_type=other)</sup> [![Chat with Dosu](https://dosu.dev/dosu-chat-badge.svg)](https://app.dosu.dev/6088a4f4-073a-43f3-b3d4-4f06fb0c05a0/ask?utm_source=github)&nbsp;[![Open in Cursor](https://dosu.dev/dosu-in-cursor.svg)](https://cursor.com/link/prompt?text=The%20404%20errors%20for%20assets%20under%20%60/serwist/%60%20are%20likely%20because%20these%20files%20aren%27t%20being%20generated%20or%20included%20in%20the%20service%20worker%27s%20precache%20manifest%20during%20build.%20In%20Dify%2C%20assets%20like%20%60/ogo/logo.svg%60%20are%20served%20directly%20from%20the%20%60public%60%20directory%2C%20but%20%60/serwist/%60%20assets%20rely%20on%20the%20service%20worker%20and%20its%20manifest%2C%20which%20is%20built%20using%20the%20Serwist%20tooling%20and%20Next.js%20app%20router.%20If%20the%20files%20aren%27t%20present%20in%20the%20build%20output%20or%20aren%27t%20referenced%20in%20the%20manifest%2C%20requests%20will%20404%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/blob/9d38af6d99d6a2f2b64004895d154ae5d59ca64d/web/app/sw.ts%23L5-L105%29%29.%0A%0ACheck%20that%20the%20assets%20you%20expect%20under%20%60/serwist/%60%20actually%20exist%20in%20your%20source%20directories%20before%20building.%20Also%2C%20make%20sure%20your%20Docker%20build%20sets%20the%20%60NEXT_PUBLIC_BASE_PATH%60%20environment%20variable%20correctly%2C%20as%20recent%20changes%20allow%20this%20to%20be%20set%20dynamically%20and%20it%20affects%20asset%20routing%20%28%5Bsource%5D%28https%3A//github.com/langgenius/dify/pull/29836%29%29.%20If%20the%20assets%20are%20missing%20from%20the%20build%20output%20or%20not%20referenced%20in%20the%20manifest%2C%20add%20them%20to%20the%20appropriate%20source%20directory%20and%20rebuild.%0A%0AIf%20you%20need%20to%20verify%2C%20inspect%20the%20build%20output%20for%20the%20presence%20of%20%60/serwist/logo/logo.svg%60%20and%20check%20that%20the%20service%20worker%20manifest%20includes%20it.%20If%20not%2C%20update%20your%20build%20config%20or%20asset%20locations%20so%20these%20files%20are%20picked%20up%20and%20precached.)&nbsp;[![Join Discord](https://img.shields.io/badge/join-5865F2?logo=discord&logoColor=white&label=)](https://go.dosu.dev/discord-bot)&nbsp;[![Share on X](https://img.shields.io/badge/X-share-black)](https://twitter.com/intent/tweet?text=%40dosu_ai%20helped%20me%20solve%20this%20issue!&url=https%3A//github.com/langgenius/dify/issues/31488)
Author
Owner

@xiezhazha commented on GitHub (Jan 27, 2026):

你好,请问你这个问题解决了吗,我这边也遇到同样的问题,目前还没有解决掉

@xiezhazha commented on GitHub (Jan 27, 2026): 你好,请问你这个问题解决了吗,我这边也遇到同样的问题,目前还没有解决掉
Author
Owner

@jasonfish568 commented on GitHub (Jan 27, 2026):

Image

I think it might be caused from here that a /serwist/ is added to the swUrl. All relative paths it calls then have /serwist added?

@jasonfish568 commented on GitHub (Jan 27, 2026): <img width="1411" height="568" alt="Image" src="https://github.com/user-attachments/assets/813384b6-bd5b-43ac-9473-3a31ae553a86" /> I think it might be caused from here that a /serwist/ is added to the swUrl. All relative paths it calls then have /serwist added?
Author
Owner

@jasonfish568 commented on GitHub (Jan 27, 2026):

Yes. So potential fixes are:

// app/sw.ts CHANGE ACCORDINGLY
const scopePathname = new URL(self.registration.scope).pathname
const basePath = scopePathname.replace(/\/serwist\/$/, '').replace(/\/$/, '')

const toAbsolute = (u: string) => {
  // skip absolute paths
  if (u.startsWith('/') || /^(https?:)?\/\//.test(u) || u.startsWith('data:')) return u
  // transform relative paths to absolute paths
  return `${basePath}/${u}`.replace(/\/{2,}/g, '/')
}

const precacheEntries = (self.__SW_MANIFEST ?? []).map((e) => {
  if (typeof e === 'string') return toAbsolute(e)
  return { ...e, url: toAbsolute(e.url) }
})

const serwist = new Serwist({
  precacheEntries,

or simply change:

const swUrl = `${basePath}/serwist/sw.js`

to

const swUrl = `${basePath}/sw.js`

If someone is keen to try the above AI generated solutions.

@jasonfish568 commented on GitHub (Jan 27, 2026): Yes. So potential fixes are: ``` // app/sw.ts CHANGE ACCORDINGLY const scopePathname = new URL(self.registration.scope).pathname const basePath = scopePathname.replace(/\/serwist\/$/, '').replace(/\/$/, '') const toAbsolute = (u: string) => { // skip absolute paths if (u.startsWith('/') || /^(https?:)?\/\//.test(u) || u.startsWith('data:')) return u // transform relative paths to absolute paths return `${basePath}/${u}`.replace(/\/{2,}/g, '/') } const precacheEntries = (self.__SW_MANIFEST ?? []).map((e) => { if (typeof e === 'string') return toAbsolute(e) return { ...e, url: toAbsolute(e.url) } }) const serwist = new Serwist({ precacheEntries, ``` or simply change: ``` const swUrl = `${basePath}/serwist/sw.js` to const swUrl = `${basePath}/sw.js` ``` If someone is keen to try the above AI generated solutions.
Author
Owner

@xiezhazha commented on GitHub (Jan 29, 2026):

图像 我认为问题可能出在这里,因为 swUrl 后面添加了 /serwist/。之后它调用的所有相对路径都会被加上 /serwist/ 吗?

嗯 我之前有想过这里路径的问题 但是我在想一个问题 这里之前加上 serwist 是为什么呢 这个应该是做预缓存的加载库,如果去掉会对缓存的资源内容有什么影响吗 就是试图从作者的角度来看待这个serwist添加的作用,而不是说之后去规避这个错误

@xiezhazha commented on GitHub (Jan 29, 2026): > <img alt="图像" width="1411" height="568" src="https://private-user-images.githubusercontent.com/5446195/541128229-813384b6-bd5b-43ac-9473-3a31ae553a86.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njk2NzI2NDcsIm5iZiI6MTc2OTY3MjM0NywicGF0aCI6Ii81NDQ2MTk1LzU0MTEyODIyOS04MTMzODRiNi1iZDViLTQzYWMtOTQ3My0zYTMxYWU1NTNhODYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDEyOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjAxMjlUMDczOTA3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTA3NDg1MThlODlhMTlhN2ViZTI0ZGZmYWNkYWRlNmJmMDA2MDAzZGNiYTdmMGVhMzNjOWQxNzc5YzY1NmU5MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.KSUxJ31KcA2FoW7-OrdrtmpNinayQ53rv8aTIQp6h50"> > 我认为问题可能出在这里,因为 swUrl 后面添加了 /serwist/。之后它调用的所有相对路径都会被加上 /serwist/ 吗? 嗯 我之前有想过这里路径的问题 但是我在想一个问题 这里之前加上 serwist 是为什么呢 这个应该是做预缓存的加载库,如果去掉会对缓存的资源内容有什么影响吗 就是试图从作者的角度来看待这个serwist添加的作用,而不是说之后去规避这个错误
Author
Owner

@jasonfish568 commented on GitHub (Jan 29, 2026):

图像 我认为问题可能出在这里,因为 swUrl 后面添加了 /serwist/。之后它调用的所有相对路径都会被加上 /serwist/ 吗?

嗯 我之前有想过这里路径的问题 但是我在想一个问题 这里之前加上 serwist 是为什么呢 这个应该是做预缓存的加载库,如果去掉会对缓存的资源内容有什么影响吗 就是试图从作者的角度来看待这个serwist添加的作用,而不是说之后去规避这个错误

So if you see my later reply the two options I provided. This is from a service worker. It does more than precache I reckon. Removing the /serwist prefix shouldn't hurt.

If anyone would like to give it a go we can then figure out.

In the meantime, I don't think it actually breaks anything. The error was caused during precaching but when the element is acutally loaded on the page it still loads.

@jasonfish568 commented on GitHub (Jan 29, 2026): > > <img alt="图像" width="1411" height="568" src="https://private-user-images.githubusercontent.com/5446195/541128229-813384b6-bd5b-43ac-9473-3a31ae553a86.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njk2NzI2NDcsIm5iZiI6MTc2OTY3MjM0NywicGF0aCI6Ii81NDQ2MTk1LzU0MTEyODIyOS04MTMzODRiNi1iZDViLTQzYWMtOTQ3My0zYTMxYWU1NTNhODYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDEyOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjAxMjlUMDczOTA3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTA3NDg1MThlODlhMTlhN2ViZTI0ZGZmYWNkYWRlNmJmMDA2MDAzZGNiYTdmMGVhMzNjOWQxNzc5YzY1NmU5MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.KSUxJ31KcA2FoW7-OrdrtmpNinayQ53rv8aTIQp6h50"> > > 我认为问题可能出在这里,因为 swUrl 后面添加了 /serwist/。之后它调用的所有相对路径都会被加上 /serwist/ 吗? > > 嗯 我之前有想过这里路径的问题 但是我在想一个问题 这里之前加上 serwist 是为什么呢 这个应该是做预缓存的加载库,如果去掉会对缓存的资源内容有什么影响吗 就是试图从作者的角度来看待这个serwist添加的作用,而不是说之后去规避这个错误 So if you see my later reply the two options I provided. This is from a service worker. It does more than precache I reckon. Removing the /serwist prefix shouldn't hurt. If anyone would like to give it a go we can then figure out. In the meantime, I don't think it actually breaks anything. The error was caused during precaching but when the element is acutally loaded on the page it still loads.
Author
Owner

@xiezhazha commented on GitHub (Jan 29, 2026):

图像 我认为问题可能出在这里,因为 swUrl 后面添加了 /serwist/。之后它调用的所有相对路径都会被加上 /serwist/ 吗?

嗯我之前有预见这里路径的问题但是我在想一个问题这里在加上serwist之前是为什么呢这个应该是做预服务器的加载库,如果去掉对服务器的资源有什么影响吗就是尝试从作者的角度来看这个serwist添加的作用,而不是说之后去规避这个错误

所以,如果你看到我后面的回复,就会发现我提供了两个选项。这是来自 Service Worker 的。我认为它的功能不仅仅是预缓存。移除 /serwist 前缀应该不会有什么影响。

如果有人想尝试一下,我们可���一起想办法。

目前来看,我认为这并没有造成任何实际问题。错误是在预缓存过程中引起的,但当元素实际加载到页面上时,它仍然可以正常加载。

好的 感谢回复 还想问个问题

你有没有遇到过这样一个报错

Image 是sw.js文件加载404 这里是路径不对还是没访问到还是别的什么原因啊 请问你有遇到过吗

@xiezhazha commented on GitHub (Jan 29, 2026): > > > <img alt="图像" width="1411" height="568" src="https://private-user-images.githubusercontent.com/5446195/541128229-813384b6-bd5b-43ac-9473-3a31ae553a86.png?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3Njk2NzI2NDcsIm5iZiI6MTc2OTY3MjM0NywicGF0aCI6Ii81NDQ2MTk1LzU0MTEyODIyOS04MTMzODRiNi1iZDViLTQzYWMtOTQ3My0zYTMxYWU1NTNhODYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI2MDEyOSUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNjAxMjlUMDczOTA3WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MTA3NDg1MThlODlhMTlhN2ViZTI0ZGZmYWNkYWRlNmJmMDA2MDAzZGNiYTdmMGVhMzNjOWQxNzc5YzY1NmU5MyZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QifQ.KSUxJ31KcA2FoW7-OrdrtmpNinayQ53rv8aTIQp6h50"> > > > 我认为问题可能出在这里,因为 swUrl 后面添加了 /serwist/。之后它调用的所有相对路径都会被加上 /serwist/ 吗? > > > > > > 嗯我之前有预见这里路径的问题但是我在想一个问题这里在加上serwist之前是为什么呢这个应该是做预服务器的加载库,如果去掉对服务器的资源有什么影响吗就是尝试从作者的角度来看这个serwist添加的作用,而不是说之后去规避这个错误 > > 所以,如果你看到我后面的回复,就会发现我提供了两个选项。这是来自 Service Worker 的。我认为它的功能不仅仅是预缓存。移除 /serwist 前缀应该不会有什么影响。 > > 如果有人想尝试一下,我们可���一起想办法。 > > 目前来看,我认为这并没有造成任何实际问题。错误是在预缓存过程中引起的,但当元素实际加载到页面上时,它仍然可以正常加载。 好的 感谢回复 还想问个问题 你有没有遇到过这样一个报错 <img width="1659" height="157" alt="Image" src="https://github.com/user-attachments/assets/6fa5cefc-4b44-4b4d-b84f-6e34abae5302" /> 是sw.js文件加载404 这里是路径不对还是没访问到还是别的什么原因啊 请问你有遇到过吗
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langgenius/dify#21877