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

Brigitta-Roberta Rucz 1 Reputation point
2021-09-30T14:06:53.397+00:00

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
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,664 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,611 Reputation points Microsoft Employee
    2021-10-01T09:36:16.17+00:00

    @Brigitta-Roberta Rucz 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.

    0 comments No comments