toeverything / AFFiNE

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.
https://affine.pro
Other
39.82k stars 2.57k forks source link

Self-host can not Paste images copied from other web pages. #6485

Open emengweb opened 4 months ago

emengweb commented 4 months ago

What happened?

Self-host Affine can not Paste images copied from other web pages, and download of images not work.

Judgment reason: The following url mapping is missing: imageProxyUrl: '/api/worker/image-proxy', linkPreviewUrl: '/api/worker/link-preview',

Distribution version

macOS x64 (Intel)

What browsers are you seeing the problem on if you're using web version?

Chrome

Are you self-hosting?

Relevant log output

No response

Anything else?

No response

affine-issue-bot[bot] commented 4 months ago

Issue Status: 🆕 *Untriaged

*🆕 Untriaged**

The team has not yet reviewed the issue. We usually do it within one business day. Docs: https://github.com/toeverything/AFFiNE/blob/canary/docs/issue-triaging.md

This is an automatic reply by the bot.

pengx17 commented 4 months ago

might be a duplicate of https://github.com/toeverything/AFFiNE/issues/5944 web clipboard api is not usable without using https

emengweb commented 4 months ago

i think its not the same, because paste image the url route access return homepage code. Looks like some url mapping is missing couse this happen.

Peng Xiao @.***> 于 2024年4月8日周一 17:06写道:

might be a duplicate of #5944 https://github.com/toeverything/AFFiNE/issues/5944 web clipboard api is not usable without using https

— Reply to this email directly, view it on GitHub https://github.com/toeverything/AFFiNE/issues/6485#issuecomment-2042238784, or unsubscribe https://github.com/notifications/unsubscribe-auth/AHQDBK52XQW234XG5QWR4EDY4JMYZAVCNFSM6AAAAABF4JF3XKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDANBSGIZTQNZYGQ . You are receiving this because you authored the thread.Message ID: @.***>

hch5184 commented 4 months ago

might be a duplicate of #5944 web clipboard api is not usable without using https

i used https, it still can not work

javix64 commented 4 months ago

might be a duplicate of #5944 web clipboard api is not usable without using https

i used https, it still can not work

can you explain how did you integrate https? I would like to.

hch5184 commented 4 months ago

might be a duplicate of #5944 web clipboard api is not usable without using https

i used https, it still can not work

can you explain how did you integrate https? I would like to.

nginx

hch5184 commented 4 months ago

What happened?

Self-host Affine can not Paste images copied from other web pages, and download of images not work.

Judgment reason: The following url mapping is missing: imageProxyUrl: '/api/worker/image-proxy', linkPreviewUrl: '/api/worker/link-preview',

Distribution version

macOS x64 (Intel)

What browsers are you seeing the problem on if you're using web version?

Chrome

Are you self-hosting?

  • [x] Yes

Relevant log output

No response

Anything else?

No response

i found the repository https://github.com/toeverything/affine-workers

but can only deploy in Cloudflare

you can make wheel by yourself in other programming languages

matheusriios commented 4 months ago

Some updates about that? I'm having the same issue.

https://discordapp.com/channels/959027316334407691/1231935115303718953

pengx17 commented 4 months ago

I see. Sorry about the statement I made about https. It clearly related to the image-proxy issue. It looks like we haven't including workers in the self-host version. Before we do, you need to either deploy https://github.com/toeverything/affine-workers onto a cloud service like Cloudflare, or adopt the code to make it running on your server somehow, which should not be too difficult.

eikaramba commented 2 months ago

i tried to deploy the cloudflare worker but there were too many obstacles along the way. i have rewritten the worker now as a simple express app which can be deployed locally via docker. i only tried out the link-preview endpoint (is the image proxy used anywhere else apart from within the link preview endpoint?) and it works flawlessly now. https://github.com/eikaramba/affine-workers

emengweb commented 1 month ago

我尝试部署 cloudflare worker,但一路上遇到了太多障碍。我现在已经将 worker 重写为一个简单的 express 应用程序,可以通过 docker 在本地部署。我只尝试了 link-preview 端点(除了在 link preview 端点内,图像代理是否在其他地方使用?)现在它运行完美。https ://github.com/eikaramba/affine-workers

it worked!

picolino commented 1 month ago

@eikaramba how did you change default base url for image-proxy? My self hosted affine still trying to call app.affine.pro instead of my hosting domain, but other urls works properly.

eikaramba commented 1 month ago

@picolino i didn't needed to change anything in my self hosted affine. it was by default calling the local endpoint, resp. trying to. e.g. https://my.local.affine.domain/api/worker/link-preview

then i added a manual redirect in nginx to let this redirect to the docker container running this worker and voila, it worked.

are you sure it is trying to connect to app.affine.pro ? add a youtube link and then click on the link and switch to card view instead inline and observe with the browser tools in the network tab what is going on then.

i'm on latest affine as of today: 0.15.7 editor 0.16.0-canary-202407200848-42035fe

eikaramba commented 1 month ago

i now see you are talking about the image-proxy. i honestly haven't tried this out and frankly i don't know how. how do you test this?

picolino commented 1 month ago

@eikaramba

To test this just press Reload on link block image

It is ok for link-preview, it is my host: image

But not for image-preview: image

As you can see - no images on link block persists.

I don't understand why is this happening...

eikaramba commented 1 month ago

strange i tested to embed https://github.com/toeverything/AFFiNE as a link

grafik

works fine. it has to be because of what the link-preview is returning for you.

Did you set the host name in the docker environment correctly?

services:
  worker:
    build: .
    expose:
      - 9930
    ports:
      - 9930:3000
    environment:
      - HOST_NAMES=${HOST_NAMES}
networks: {}

where HOST_NAMES is a variable i have set. e.g. HOST_NAMES=https://my.affine.instance

picolino commented 1 month ago

@eikaramba Nah, I used app.affine.pro workers, because of that these workers gave me back that url.

I deployed your affine workers in docker - everything is fine.

Just to mention, if you gonna use it too:

  1. Change HOST_NAMES env in compose.yaml to: HOST_NAMES=https://\<your hostname>
  2. Change src/utils/headers.ts, add your host to allowed origins.

Also, you could inject workers compose.yaml in basic affine compose to launch both in one command:

services:
  workers:
    container_name: affine_workers
    extends:
      file: ../affine-workers/compose.yaml
      service: worker