8000 Avatars won't display if the app is migrated to a different sub-path · Issue #1776 · wekan/wekan · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Avatars won't display if the app is migrated to a different sub-path #1776

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
zypA13510 opened this issue Jul 16, 2018 · 8 comments
Closed

Comments

@zypA13510
Copy link
Contributor

Issue

Server Setup Information:

  • Did you test in newest Wekan?: yes
  • Wekan version: 1.18.0
  • Operating System: CentOS 7 (3.10.0-862.el7.x86_64)
  • Deployment Method(snap/docker/sandstorm/mongodb bundle/source): snap
  • ROOT_URL environment variable http(s)://(subdomain).example.com(/suburl):

Problem description:
When migrating Wekan to a new host, the user avatar will become inaccessible, HTTP status 404. Using the ROOR_URL above, the src attribute of the <img> tag is always pointed to /wekan/cfs/files/avatars/RandomString/filename.jpg (removing the /wekan part from Chrome Dev Tools after migration will load the image correctly).

When viewing the data from mongo CLI, I discovered that the sub-path is stored into the DB:

> use wekan
> db.users.find()
{
    ...
    "profile" : {
        ...
        "avatarUrl" : "/wekan/cfs/files/avatars/_________________/____.jpg",
        ...
    },
    ...
}

Interestingly, also stored in /cfs, attachments work fine after migration. If the attachment is an image file, the preview loads correctly.

Maybe related to #386, #973.

Steps to reproduce:

  1. Set up Wekan-snap using the old ROOT_URL above.
  2. Perform a DB backup wekan-snap backup and restore
  3. Set up Wekan-docker (or probably another Wekan-snap, not tested) with the new ROOT_URL
  4. Perform a DB restore wekan-docker export mongo data

Workaround:
Not tested yet, but theoretically, one can use the mongo CLI to replace the old sub-path with RegExp. Ref

@d3dbit
Copy link
d3dbit commented Jul 16, 2018

Hello,
I had the same issue after upgrade to v1.18 in a docker environment.
Workaround: I went to the "change avatar" section and I could select the correct avatar.

@xet7 xet7 closed this as completed in 7e0bc1e Aug 22, 2018
xet7 added a commit that referenced this issue Aug 22, 2018
  Same can be done with Caddy.

Thanks to xet7 !

Closes #1776,
closes #386
@zypA13510
Copy link
Contributor Author

Reopen?
I think we should set up the reference with an internal ID instead of a URL. And btw, attachments do not break in the same situation, so maybe just copy the solution to user avatars?

@xet7 xet7 reopened this Aug 23, 2018
@xet7
Copy link
Member
xet7 commented Aug 23, 2018

The bug is at CollectionFS, as can be seen at #386 .
Avatar URL currently needs to include subpath of ROOT_URL to display correctly, like /wekan/cfs. My javascript on the fly fix was too fragile, it did not always work. There are couple of different ways to fix this.

a) Workaround way: In wekan/server/migrations.js, check does process.env.ROOT_URL contain suburl like /wekan. If yes, search MongoDB users.profile.avatarUrl for those that do not begin with /wekan/cfs/ and change them to have that.

b) As part of #142 supporting other ways to store attachments, make all attachments to use any of those ways to store attachments with correct URLs.

@andreasgrill
Copy link
andreasgrill commented May 2, 2020

We recently experienced the same issue by changing wekan from a subpath xy.com/wekan to a sub-domain wekan.xy.com.
I used the following mongodb code to remove /wekan from the avatar URL:

db.users.find({"profile.avatarUrl": /^\/wekan\//}).forEach(function(e,i) { 
    e.profile.avatarUrl=e.profile.avatarUrl.substring(6); 
    db.users.save(e); 
});

@xet7
Copy link
Member
xet7 commented May 2, 2020

@andreasgrill

Can you try to make pull request that would at wekan/server/migrations.js check ROOT_URL does it have sub-path, and run migration to correct those avatar URLs?

@xet7
Copy link
Member
xet7 commented May 2, 2020

@andreasgrill

When sub-path changes, would that require changes to other images and attachments? You could check at MongoDB database.

@xet7
Copy link
Member
xet7 commented May 2, 2020

Thanks!

@andreasgrill
Copy link

@xet7 I’ll look into it this weekend.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants
0