gbip / sentry_tunnel

Proxy sentry request to a sentry server using a tunnel/proxy endpoint
BSD 2-Clause "Simplified" License
33 stars 12 forks source link

CORS issues #11

Closed gabrielperalchz closed 8 months ago

gabrielperalchz commented 11 months ago

Hello, I've recently deployed the sentry tunnel on a container, I had to create the docker image from the code in the repo itself because the one in docker hub seems like is not having the latest code. However, once I did that and deployed, I found issues about CORS. I was wondering if there is a way to add CORS headers to the server to about this issues The message in browser is like the following

Access to fetch at '$sentry_tunnel_url' from origin '$server_url' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

is anyone experience that or knows a way to solve it? I think the sentry tunnel should include CORS settings, isn't it?

JoeyEamigh commented 11 months ago

Hey! This project is using gotham which is a Rust web framework without an easy way to add CORS support. I created a similar project that was heavily inspired by this one using axum which includes CORS support. I made it in just a few hours today so it might not be as solid as this project, but if CORS is a make-or-break for you then feel free to give it a shot!

https://github.com/JoeyEamigh/sentry-tunneler

gabrielperalchz commented 11 months ago

Thanks for the answer!! I will take a look at yours!

Thanks a lot!

gbip commented 8 months ago

Hello, I've recently deployed the sentry tunnel on a container, I had to create the docker image from the code in the repo itself because the one in docker hub seems like is not having the latest code. However, once I did that and deployed, I found issues about CORS. I was wondering if there is a way to add CORS headers to the server to about this issues The message in browser is like the following

Access to fetch at '$sentry_tunnel_url' from origin '$server_url' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

is anyone experience that or knows a way to solve it? I think the sentry tunnel should include CORS settings, isn't it?

Since the tunnel is supposed to be reached from the same hostname as your web application, you should be using a reverse proxy of some sort.

The reverse proxy is where I would handle CORS headers as it might be out of scope for this project.