mmd-osm left a comment (openstreetmap/openstreetmap-website#6192)
I'm not sure I have enough karma points to propose such a change.
Anyway, one alternative I found is to handle the Turbo before-fetch-response
event. In case the endpoint is sending us failures in html format, we tell
Turbo to no longer follow up on this particular event. A bit later, the event
handler then longer tries to replace the current page by the HTML response,
which is what we're trying to avoid here.
```javascript
$("#export-image").on("turbo:before-fetch-response", function (event) {
const res = event.detail.fetchResponse.response;
if (!res.ok && res.headers.get("content-type")?.includes("text/html")) {
event.preventDefault();
event.stopPropagation();
}
});
```
It seems the turbo:submit-end is nevertheless triggered as an event, and as a
result we're getting this nice error popup, and nothing else:
<img width="575" height="232" alt="image"
src="https://github.com/user-attachments/assets/a7d2c4b2-74da-4d16-aaaa-424dcc6549f2"
/>
Does this seem reasonable?
--
Reply to this email directly or view it on GitHub:
https://github.com/openstreetmap/openstreetmap-website/pull/6192#issuecomment-3094716628
You are receiving this because you are subscribed to this thread.
Message ID:
<openstreetmap/openstreetmap-website/pull/6192/c3094716...@github.com>
_______________________________________________
rails-dev mailing list
rails-dev@openstreetmap.org
https://lists.openstreetmap.org/listinfo/rails-dev