sid 3835 no im using module helper for
@sdnts no im using module helper for S3 in elixir i thought that it will work as well with the s3 compat api, it sends request
4 Replies
Well if you're talking to R2 from your own backend, then:
1. Setting up a CORS config on R2's side will not do anything. CORS is a browser-only thing.
2. You'll have to return CORS headers from your Elixir server to make sure the browser is able to talk to it
So really, your issue has nothing to do with R2
but i think this module should handle that stuff, it does for s3, I believe? https://gist.github.com/chrismccord/37862f1f8b1f5148644b75d20d1cb073 this is the way to do it in liveview which is a weird hybrid of client and server in phoenix, how can I make sure that headers are set correctly?
Gist
Simple, dependency-free S3 Form Upload using HTTP POST sigv4
Simple, dependency-free S3 Form Upload using HTTP POST sigv4 - simple_s3_upload.ex
I'm not really familiar with Elixir, and especially because you say there's isomorphic stuff happening: I'd first make sure where the R2 request is happening. Logic would dictate that it is happening from your server (otherwise you'd be shipping credentials client-side).
So it's Browser <-> Your server <-> R2. Because your browser is talking to your server, you are responsible for setting the right CORS headers
hmm but again i dont understand why with aws and the same code, same cors policies, I can see in the RESPONSE headers I can clearly see the 'Access-Control-Allow-Origin' header, but not with the r2 api
turns out this module was not the right fit for the job, I have used ex_aws s3 library and it's working! Thanks, you help me get on the right track!