question

BrigittaRobertaRucz-8632 avatar image
0 Votes"
BrigittaRobertaRucz-8632 asked PramodValavala-MSFT answered

Accessing Function App from Localhost ( CORS / AppServiceAuthSession / Bearer JWT generation )

I have connected my Azure Function App on the portal and on the localhost, now up and running on :7071. Also, I have added to it an identity provider - auth0, however now I find myself in the situation of needing to access the route .auth/me. It does not work on localhost at all as the route does not exist on :7071 - cannot really understand why. However, my interest would lie in the staging Function App API Url - if I try to access that by a fetch in code I experience CORS. If I simply open it in a new tab I can clearly see it and get the AppServiceAuthSession. There's the id_token which I can also use as a Bearer JWT.

Is there any way I can access the API from localhost? Either generate AppServiceAuthSession somehow or the Bearer JWT? Eliminate CORS? ( I want to mention that I have tackled the CORS policies both on the portal and on the tenant on auth0 )

azure-functions
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

1 Answer

PramodValavala-MSFT avatar image
0 Votes"
PramodValavala-MSFT answered

@BrigittaRobertaRucz-8632 The auth endpoints are only supported when running on Azure since the middleware isn't really part of the Azure Functions runtime but rather the underlying App Service. I believe there are a couple of unofficial local testing options that try and mimic the behavior.

As for the CORS issue, you can use the --cors * when running func start locally to ensure the right headers are passed.


5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.