NextChat icon indicating copy to clipboard operation
NextChat copied to clipboard

[Bug?] [Help request] v2.11.3无法使用本地的webdav服务

Open Wedjat98 opened this issue 2 years ago • 20 comments

Bug Description

No PROXY_URL confirmed

我有一个极其简易的webdav服务如下:

const { v2: webdav } = require('webdav-server');

// 创建一个用户管理器
const userManager = new webdav.SimpleUserManager();
const user = userManager.addUser('user', 'pass', false);

// 创建权限管理器并设置权限
const privilegeManager = new webdav.SimplePathPrivilegeManager();
privilegeManager.setRights(user, '/', ['all']);

// 创建WebDAV服务器实例
const server = new webdav.WebDAVServer({
    port: 3900,
    httpAuthentication: new webdav.HTTPBasicAuthentication(userManager),
    privilegeManager: privilegeManager
});

// 设置文件系统并添加错误处理
server.setFileSystem('/', new webdav.PhysicalFileSystem('someDir/webdav'), (success, error) => {
    if (error) {
        console.error('Error setting file system:', error);
        return;
    }
    console.log(`Filesystem loaded successfully: ${success}`);
});

// 在请求开始和结束时添加详细的日志记录
server.beforeRequest((req, next) => {
    console.log(`Incoming request: ${req.method} ${req.url}`);
    console.log(`Headers: ${JSON.stringify(req.headers)}`);
    next();
});

server.afterRequest((req, next) => {
    console.log(`Completed request: ${req.method} ${req.url} - Status: ${req.response.statusCode}`);
    next();
});

// 启动服务器
server.start(() => console.log('WebDAV server started on port 3900'));

我在v2.11.2 是可以正常使用这个服务来同步对话历史到不同的设备,但是升级至v2.11.3我无法使用了。请问我应该怎么做?或者我应该从哪里获取到同步失败的相关log?

Steps to Reproduce

update to 2.11.3 and Sync the chat histories then show dialog Sync Fail

Expected Behavior

Sync Success

Screenshots

No response

Deployment Method

  • [ ] Docker
  • [ ] Vercel
  • [X] Server

Desktop OS

No response

Desktop Browser

No response

Desktop Browser Version

No response

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

No response

Wedjat98 avatar Mar 18 '24 05:03 Wedjat98

Please follow the issue template to update title and description of your issue.

nextchat-manager[bot] avatar Mar 18 '24 05:03 nextchat-manager[bot]

Bot detected the issue body's language is not English, translate it automatically.


Title: [Bug?] [Help request] v2.11.3 cannot use the local webdav service

Issues-translate-bot avatar Mar 18 '24 05:03 Issues-translate-bot

@Wedjat98 could you share the console log from your browser when sync with webdav?

fred-bf avatar Mar 18 '24 05:03 fred-bf

@fred-bf

Sure! Here is it.

[Sync] failed to get remote state TypeError: URL constructor: /api/cors//api/webdav/chatgpt-next-web/backup.json/ is not a valid URL.
    NextJS 33
[page-606a277117982b1d.js:1:232420](http://192.168.0.244:3000/_next/static/chunks/app/page-606a277117982b1d.js)
[Sync] TypeError: URL constructor: /api/cors//api/webdav/chatgpt-next-web/backup.json/ is not a valid URL.
    NextJS 33
[7698-bb5d18468650f39a.js:1:3423](http://192.168.0.244:3000/_next/static/chunks/7698-bb5d18468650f39a.js)
    NextJS 31

Wedjat98 avatar Mar 18 '24 05:03 Wedjat98

I have the save issue

mosimod avatar Mar 18 '24 17:03 mosimod

working on it, it should cause by a recent security update

fred-bf avatar Mar 19 '24 09:03 fred-bf

我在使用坚果云webdav,点击“同步”显示成功了,但是去网盘实际看文件没有更新

MC-dusk avatar Mar 19 '24 11:03 MC-dusk

Bot detected the issue body's language is not English, translate it automatically.


I am using Nut Cloud webdav. When I click "Synchronize", it shows success, but when I go to the network disk to actually view the file, it is not updated.

Issues-translate-bot avatar Mar 19 '24 11:03 Issues-translate-bot

我在使用坚果云webdav,点击“同步”显示成功了,但是去网盘实际看文件没有更新

MC-dusk avatar Mar 19 '24 11:03 MC-dusk

Bot detected the issue body's language is not English, translate it automatically.


I am using Nut Cloud webdav. When I click "Synchronize", it shows success, but when I go to the network disk to actually view the file, it is not updated.

Issues-translate-bot avatar Mar 19 '24 11:03 Issues-translate-bot

我在使用坚果云webdav,点击“同步”显示成功了,但是去网盘实际看文件没有更新

同样也遇到了这个问题

yuluod avatar Mar 19 '24 14:03 yuluod

Bot detected the issue body's language is not English, translate it automatically.


I am using Nut Cloud webdav. Clicking "Sync" shows success, but when I go to the network disk to actually view the file, it is not updated.

Also encountered this problem

Issues-translate-bot avatar Mar 19 '24 14:03 Issues-translate-bot

Bug Description

No PROXY_URL confirmed

我有一个极其简易的webdav服务如下:

const { v2: webdav } = require('webdav-server');

// 创建一个用户管理器
const userManager = new webdav.SimpleUserManager();
const user = userManager.addUser('user', 'pass', false);

// 创建权限管理器并设置权限
const privilegeManager = new webdav.SimplePathPrivilegeManager();
privilegeManager.setRights(user, '/', ['all']);

// 创建WebDAV服务器实例
const server = new webdav.WebDAVServer({
    port: 3900,
    httpAuthentication: new webdav.HTTPBasicAuthentication(userManager),
    privilegeManager: privilegeManager
});

// 设置文件系统并添加错误处理
server.setFileSystem('/', new webdav.PhysicalFileSystem('someDir/webdav'), (success, error) => {
    if (error) {
        console.error('Error setting file system:', error);
        return;
    }
    console.log(`Filesystem loaded successfully: ${success}`);
});

// 在请求开始和结束时添加详细的日志记录
server.beforeRequest((req, next) => {
    console.log(`Incoming request: ${req.method} ${req.url}`);
    console.log(`Headers: ${JSON.stringify(req.headers)}`);
    next();
});

server.afterRequest((req, next) => {
    console.log(`Completed request: ${req.method} ${req.url} - Status: ${req.response.statusCode}`);
    next();
});

// 启动服务器
server.start(() => console.log('WebDAV server started on port 3900'));

我在v2.11.2 是可以正常使用这个服务来同步对话历史到不同的设备,但是升级至v2.11.3我无法使用了。请问我应该怎么做?或者我应该从哪里获取到同步失败的相关log?

Steps to Reproduce

update to 2.11.3 and Sync the chat histories then show dialog Sync Fail

Expected Behavior

Sync Success

Screenshots

No response

Deployment Method

  • [ ] Docker
  • [ ] Vercel
  • [x] Server

Desktop OS

No response

Desktop Browser

No response

Desktop Browser Version

No response

Smartphone Device

No response

Smartphone OS

No response

Smartphone Browser

No response

Smartphone Browser Version

No response

Additional Logs

No response

try this #4353

H0llyW00dzZ avatar Mar 19 '24 18:03 H0llyW00dzZ

@H0llyW00dzZ Thx for your help. I have tried your version. But it didn't worked as well.

When I clicked the Check Connection button, Console showed this:

XHRMKCOL
[http://192.168.0.244:3000/api/upstash/chatgpt-next-web?endpoint=http://192.168.0.244:3900](http://192.168.0.244:3000/api/upstash/chatgpt-next-web?endpoint=http%3A%2F%2F192.168.0.244%3A3900)
[HTTP/1.1 404 Not Found 30ms]

[WebDav] check 404 Not Found [page-1b933c022a7b0acd.js:1:239001](http://192.168.0.244:3000/_next/static/chunks/app/page-1b933c022a7b0acd.js)

btw the sysc status icon seems like turned checked, that isn't true. image

Sync button showed this:

XHRGET
[http://192.168.0.244:3000/api/upstash/chatgpt-next-web/backup.json?endpoint=http://192.168.0.244:3900](http://192.168.0.244:3000/api/upstash/chatgpt-next-web/backup.json?endpoint=http%3A%2F%2F192.168.0.244%3A3900)
[HTTP/1.1 403 Forbidden 31ms]

[WebDav] get key =  admin 403 Forbidden [page-1b933c022a7b0acd.js:1:239257](http://192.168.0.244:3000/_next/static/chunks/app/page-1b933c022a7b0acd.js)
[Sync] failed to get remote state TypeError: t is undefined
    NextJS 34
[page-1b933c022a7b0acd.js:1:232439](http://192.168.0.244:3000/_next/static/chunks/app/page-1b933c022a7b0acd.js)

Hope those log is useful to your work.

Thx again.

Wedjat98 avatar Mar 21 '24 11:03 Wedjat98

I have rolled back to the v2.11.2. When I clicked the Check Connection button, Console showed this:

[CORS] target =  /api/cors/http/192.168.0.244:3900/chatgpt-next-web [page-8ad94c71eb7e5987.js:1:236651](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
XHRPOST
http://192.168.0.244:3000/api/cors/http/192.168.0.244:3900/chatgpt-next-web
[HTTP/1.1 405 Method Not Allowed 56ms]

I have check this request seems like to create a directory(?) by MKCOL method. Normally MKCOL is acceptable.

When I click the Sync button Console showed this:

[WebDav] check 405 Method Not Allowed [page-8ad94c71eb7e5987.js:1:235317](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
[CORS] target =  /api/cors/http/192.168.0.244:3900/chatgpt-next-web/backup.json [page-8ad94c71eb7e5987.js:1:236651](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
XHRPOST
http://192.168.0.244:3000/api/cors/http/192.168.0.244:3900/chatgpt-next-web/backup.json
[HTTP/1.1 404 Not Found 50ms]

[WebDav] get key =  admin 404 Not Found [page-8ad94c71eb7e5987.js:1:235584](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
[Sync] failed to get remote state SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
    NextJS 32
[page-8ad94c71eb7e5987.js:1:228903](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
[CORS] target =  /api/cors/http/192.168.0.244:3900/chatgpt-next-web/backup.json [page-8ad94c71eb7e5987.js:1:236651](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
[WebDav] set key =  admin 201 Created

then Sync is successful and file backup.json is created.

Wedjat98 avatar Mar 22 '24 00:03 Wedjat98

@H0llyW00dzZ Thx for your help. I have tried your version. But it didn't worked as well.

When I clicked the Check Connection button, Console showed this:

XHRMKCOL
[http://192.168.0.244:3000/api/upstash/chatgpt-next-web?endpoint=http://192.168.0.244:3900](http://192.168.0.244:3000/api/upstash/chatgpt-next-web?endpoint=http%3A%2F%2F192.168.0.244%3A3900)
[HTTP/1.1 404 Not Found 30ms]

[WebDav] check 404 Not Found [page-1b933c022a7b0acd.js:1:239001](http://192.168.0.244:3000/_next/static/chunks/app/page-1b933c022a7b0acd.js)

btw the sysc status icon seems like turned checked, that isn't true. image

Sync button showed this:

XHRGET
[http://192.168.0.244:3000/api/upstash/chatgpt-next-web/backup.json?endpoint=http://192.168.0.244:3900](http://192.168.0.244:3000/api/upstash/chatgpt-next-web/backup.json?endpoint=http%3A%2F%2F192.168.0.244%3A3900)
[HTTP/1.1 403 Forbidden 31ms]

[WebDav] get key =  admin 403 Forbidden [page-1b933c022a7b0acd.js:1:239257](http://192.168.0.244:3000/_next/static/chunks/app/page-1b933c022a7b0acd.js)
[Sync] failed to get remote state TypeError: t is undefined
    NextJS 34
[page-1b933c022a7b0acd.js:1:232439](http://192.168.0.244:3000/_next/static/chunks/app/page-1b933c022a7b0acd.js)

Hope those log is useful to your work.

Thx again.

It seems that the issue is because the /api/cors/ route was removed, which caused a conflict between the client-side and server-side code.

I have rolled back to the v2.11.2. When I clicked the Check Connection button, Console showed this:

[CORS] target =  /api/cors/http/192.168.0.244:3900/chatgpt-next-web [page-8ad94c71eb7e5987.js:1:236651](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
XHRPOST
http://192.168.0.244:3000/api/cors/http/192.168.0.244:3900/chatgpt-next-web
[HTTP/1.1 405 Method Not Allowed 56ms]

I have check this request seems like to create a directory(?) by MKCOL method. Normally MKCOL is acceptable.

When I click the Sync button Console showed this:

[WebDav] check 405 Method Not Allowed [page-8ad94c71eb7e5987.js:1:235317](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
[CORS] target =  /api/cors/http/192.168.0.244:3900/chatgpt-next-web/backup.json [page-8ad94c71eb7e5987.js:1:236651](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
XHRPOST
http://192.168.0.244:3000/api/cors/http/192.168.0.244:3900/chatgpt-next-web/backup.json
[HTTP/1.1 404 Not Found 50ms]

[WebDav] get key =  admin 404 Not Found [page-8ad94c71eb7e5987.js:1:235584](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
[Sync] failed to get remote state SyntaxError: JSON.parse: unexpected end of data at line 1 column 1 of the JSON data
    NextJS 32
[page-8ad94c71eb7e5987.js:1:228903](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
[CORS] target =  /api/cors/http/192.168.0.244:3900/chatgpt-next-web/backup.json [page-8ad94c71eb7e5987.js:1:236651](http://192.168.0.244:3000/_next/static/chunks/app/page-8ad94c71eb7e5987.js)
[WebDav] set key =  admin 201 Created

then Sync is successful and file backup.json is created.

For the old version, you may need to temporarily block internal IP addresses because the old version might still be vulnerable to Server-Side Request Forgery (SSRF) when hosted on cloud platforms like AWS due to lack of proper configuration or misconfiguration.

H0llyW00dzZ avatar Mar 22 '24 14:03 H0llyW00dzZ

Also, I have already found and identified a better method for handling this issue. However, I plan to start implementing it next month after Eid Mubarak, as I currently don't have much free time available.

H0llyW00dzZ avatar Mar 22 '24 14:03 H0llyW00dzZ

我在使用坚果云webdav,点击“同步”显示成功了,但是去网盘实际看文件没有更新

我也遇到了这个问题

0verleaves avatar Apr 01 '24 13:04 0verleaves

Bot detected the issue body's language is not English, translate it automatically.


I am using Nut Cloud webdav. Clicking "Sync" shows success, but when I go to the network disk to actually view the file, it is not updated.

I also encountered this problem

Issues-translate-bot avatar Apr 01 '24 13:04 Issues-translate-bot

使用同样的upstash地址和token,2.10.3可以同步,2.11.3同步失败: image

jetaimy avatar Apr 03 '24 08:04 jetaimy

同样问题,今天更新了最新的代码试了infini-cloud.net的webdav网盘,显示同步成功,但是网盘里空空如也

404gods avatar Apr 11 '24 06:04 404gods

Bot detected the issue body's language is not English, translate it automatically.


I have the same problem. I updated the latest code today and tried the webdav network disk of infini-cloud.net. It shows that the synchronization is successful, but the network disk is empty.

Issues-translate-bot avatar Apr 11 '24 06:04 Issues-translate-bot

image

image Cause: proxyUrl's value in frontend is /, then the relative path is not a valid URL Solution: set proxyUrl to your domain

SakuraKoi avatar Apr 11 '24 06:04 SakuraKoi

使用同样的upstash地址和token,2.10.3可以同步,2.11.3同步失败: image

it has been fixed in this pr https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web/pull/4525

Dean-YZG avatar Apr 16 '24 07:04 Dean-YZG

it has been fixed in this pr #4525

@Dean-YZG json parse error in new pr.

Logs
page-df770995f097e59f.js:1 [Config] got config from build time {version: 'v2.11.3', commitDate: '1713250762000', commitHash: '9b2cb1e1c3252298c8a94fb195af683ac7aea5e9', buildMode: 'standalone', isApp: false}
serviceWorkerRegister.js:4 ServiceWorker registration successful with scope:  https://exmaple.com/
670.3f8d4b1ccea09673.js:1 [Update] local version  v2.11.3
670.3f8d4b1ccea09673.js:1 [Update] remote version  v2.11.3
page-df770995f097e59f.js:1 [Config] got config from server {needCode: true, hideUserApiKey: false, disableGPT4: false, hideBalanceQuery: true, disableFastLink: false, …}
page-df770995f097e59f.js:1 
        
        
       GET https://example.com/api/webdav/chatgpt-next-web/backup.json?endpoint=https://dav.jianguoyun.com/dav/ 520
get @ page-df770995f097e59f.js:1
sync @ page-df770995f097e59f.js:1
onClick @ 670.3f8d4b1ccea09673.js:1
l5 @ bce60fc1-e55b90606913faf1.js:9
ar @ bce60fc1-e55b90606913faf1.js:9
(anonymous) @ bce60fc1-e55b90606913faf1.js:9
u2 @ bce60fc1-e55b90606913faf1.js:9
u3 @ bce60fc1-e55b90606913faf1.js:9
(anonymous) @ bce60fc1-e55b90606913faf1.js:9
oS @ bce60fc1-e55b90606913faf1.js:9
ir @ bce60fc1-e55b90606913faf1.js:9
u9 @ bce60fc1-e55b90606913faf1.js:9
i6 @ bce60fc1-e55b90606913faf1.js:9
i4 @ bce60fc1-e55b90606913faf1.js:9
page-df770995f097e59f.js:1 [WebDav] get key =  [email protected] 520 
page-df770995f097e59f.js:1 [Sync] failed to get remote state SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
    at Object.sync (page-df770995f097e59f.js:1:247469)
    at async onClick (670.3f8d4b1ccea09673.js:1:16330)
7698-bb5d18468650f39a.js:1 [Sync] SyntaxError: Unexpected token '<', "<!DOCTYPE "... is not valid JSON
    at JSON.parse (<anonymous>)
    at Object.sync (page-df770995f097e59f.js:1:247469)
    at async onClick (670.3f8d4b1ccea09673.js:1:16330)
window.console.error @ 7698-bb5d18468650f39a.js:1
onClick @ 670.3f8d4b1ccea09673.js:1
await in onClick (async)
l5 @ bce60fc1-e55b90606913faf1.js:9
ar @ bce60fc1-e55b90606913faf1.js:9
(anonymous) @ bce60fc1-e55b90606913faf1.js:9
u2 @ bce60fc1-e55b90606913faf1.js:9
u3 @ bce60fc1-e55b90606913faf1.js:9
(anonymous) @ bce60fc1-e55b90606913faf1.js:9
oS @ bce60fc1-e55b90606913faf1.js:9
ir @ bce60fc1-e55b90606913faf1.js:9
u9 @ bce60fc1-e55b90606913faf1.js:9
i6 @ bce60fc1-e55b90606913faf1.js:9
i4 @ bce60fc1-e55b90606913faf1.js:9

hexsix avatar Apr 16 '24 07:04 hexsix

it has been fixed in this pr #4525

还是同步失败

0verleaves avatar Apr 16 '24 11:04 0verleaves

到底应该怎样做才能同步成功?现在2.12.3版本还是不能同步

mghcool avatar May 15 '24 13:05 mghcool

Bot detected the issue body's language is not English, translate it automatically.


What should be done to achieve successful synchronization? Now version 2.12.3 still cannot be synchronized.

Issues-translate-bot avatar May 15 '24 13:05 Issues-translate-bot