Hi, folks. I’m rediscovering Elm. I’m adapting the “Book” example to display the details of the Http.Error on error responses. I was very surprised to discover that when I try to request text from this URL, I get NetworkError instead of BadStatus 404.
From my limited testing (see https://ellie-app.com/pH4j93hrLqMa1, the request is done when the application starts), it seems that this URL responds with a restrictive access-control-allow-origin https://worker.elm-lang.org, which means any request done from JavaScript is going to get rejected, unless it’s initiated by code living at https://worker.elm-lang.org.
This is likely why you’re seeing a NetworkError. You’re seeing a regular 404 when you make that request from more traditional means (direct browser request or curl) because CORS enforcement does not work the same in those cases.
Thank you! Based on your description, I’d expect even a successful request to be rejected due to CORS, but the text loads when the URL is correct. I admit, I don’t understand CORS yet.
Huh. It seems to be something about the server that’s serving these URLs. When I request the document at the correct URL, I see
access-control-allow-origin: *
and when I request a URL that almost certainly doesn’t have a document on the server, I see