Anvil.http.request Blocked by CORS

What I’m trying to do:
Call an API to get data via anvil.http.request()

What is working
From another browser (not from my Anvil site), I can retrieve the response.
The same goes with me running it from PyCharm via the requests package.

What I’ve tried and what’s not working:
My Anvil app has this request statement:
anvil.http.request(url=‘https://example.com/api/results’)

In Anvil, I receive HttpError: HTTP error 0.

The browser shows me the below. Is it normal for the Anvil request to append ‘?undefined’ at the end of the url? Is there a known solution for this?

Access to fetch at ‘https://example.com/api/results/?undefined’ from origin ‘https://5aldm6obtwfl2per.anvil.app’ 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.

Are you, by any chance, running your app from within the Ide?

If so, try running it in a separate tab or publishing it and running the published app.

I was running it from the IDE. Published app. Ran from there.
Same Request URL shown in the Headers: https://example.com/api/results?undefined
App request statement: anvil.http.request(url=‘https://example.com/api/results’)