I'm working on a local dev config using:
- Azure Function via a local func emulator from visual studio
- Accessed via Blazor WebAssembly (via local IIS express).
The goal is to develop an WebAssembly App using Azure Function emulator in a local dev config, without having to publish each time on azure to make a test...
When I try to access a dummy function from the blazor app using http.GetStringAsync() method , I'm facing a problem when accessing the func emulator via the IP address, like these explanations :
when call from the blazor app using localhost like
Http.GetStringAsync("http://localhost:7071/api/HelloEcho") => localhost , it works, I got a response
when accessing the func api from a Chrome or Edge client using the localhost or IP adress, like typing this in browser or from a remote device :
http://localhost:7071/api/HelloEcho => it works http://xxx.xxx.xxx.xxx:7071/api/HelloEcho => remote, it works
I even try taping it http://xxx.xxx.xxx.xxx:7071/api/HelloEcho in a safari browser on my phone connected on the same network ==> it works , I get a response.
- but when I'm trying to access it replacing the localhost by its IP from the blazor app like this
Http.GetStringAsync("http://xxx.xxx.xxx.xxx:7071/api/HelloEcho")=> i got an error message
WebAssembly.JSException: TypeError: Failed to fetch at System.Net.Http.WebAssemblyHttpHandler.doFetch
If it works in a browser, why not using an http.Get in the app ? and what can I do to make it working ?
NB : in the function host, added parameters for CORS : *
Visual studio Version 16.6.0 Preview 6.0
Azure Functions Core Tools (3.0.2534 Commit hash: bc1e9efa8fa78dd1a138dd1ac1ebef97aac8d78e) Function Runtime Version: 3.0.13353.0
WebAssembly 3.2.0-rc1.20223.4