stophecom / sharrr-svelte

End-to-end encrypted file transfer.
https://www.sharrr.com
MIT License
123 stars 4 forks source link

Incorrect upload URL when self hosting #301

Open whatevercauseeverythingistaken opened 1 month ago

whatevercauseeverythingistaken commented 1 month ago

Greetings,

So this is my first S3 integration like this so please bear with me because I've been thrown straight into an ocean.

I'm getting CORS errors when trying to upload something despite the public access being fully enabled in my Amazon S3 Bucket settings. Also the URL that throws CORS errors doesn't seem to be correct, it's https://bucket_name.s3.eu-north-1.amazonaws.com//bucket_name, why is that so?

Why bucket_name occurs twice in the URL and why when it's used for the second time there are double slashes before it?

Here is my env structure:

Postgres

POSTGRES_PRISMA_URL='postgres://user_name@localhost:5432/user_name' POSTGRES_URL_NON_POOLING='postgres://user_name@localhost:5432/user_name' # Direct Connection

S3 compatible object storage e.g. AWS

S3_ENDPOINT='s3.eu-north-1.amazonaws.com' S3_ACCESS_KEY='access_key' S3_SECRET_KEY='secret_access_key' PUBLIC_S3_BUCKET='bucket_name'

Vercel specific, but can be easily replaced.

VERCEL_URL='http://localhost:3000' PUBLIC_ENV='development' # preview/production

Only used for cron jobs that run using Github Actions.

API_SECRET_KEY=''

Thank you in advance.

stophecom commented 1 month ago

Hi there, actually, I had a fair amount of trouble with settings up S3 as well. I just checked and noticed that I even added some comment in https://github.com/stophecom/sharrr-svelte/blob/main/src/lib/s3.ts - but I don't recall the exact problem. Maybe it relates to https://github.com/anacronw/multer-s3/issues/192 ?

As for the CORS issue. Maybe you have some custom config on Amazon? https://docs.aws.amazon.com/AmazonS3/latest/userguide/cors.html

In my setup I use another S3 provider so I can't really help with that I'm afraid.

Hope that helps at least a bit. Best Chris