Teams App and SPFX fetch error with local hosted Azure Function


This is really a note for me so I can find it in the future. So, future me, if you are having the following problem, you are running a local dev environment that has an SPFX application (mine was a Teams App running in Teams workbench) and a local Azure Function.

For some reason, you are calling your API, but you keep getting a fetch error, no matter what you do. You read about various people complaining about CORS errors, but you think, “Nah, it’s nothing to do with that.”

Your API gets called successfully and you step through the function but between the return and switching back to your VS Code it errors.

Well, check your local.settings.json for the following entry and add it if missing.

  "Host": {
    "LocalHttpPort": 7165,
    "CORS": "*"
  }

The real hero is Eli, who provided the fix via her blog post, thanks Eli, I will be buying you a coffee!

Displaying an image of Visual Studio code with a SharePoint Framework solution open.

Tips for SharePoint Framework development presentation


Recently I delivered a talk at the Yorkshire Office 365 user group called “Tips for SharePoint Framework development”. The talk has come about my experiences working on several SharePoint Framework development engagements, including a project for a Microsoft ISV.

 

The aims of the presentation are:

  • Help developers build better SharePoint Framework solutions.
  • Help developers build more maintainable SharePoint Framework solutions.
  • Demonstrate some approaches to doing the above.
  • Highlight some of the great resources for building SPFx solutions.

If you have seen the presentation, I would appreciate your thoughts on the session. Please leave a comment below.

 

Finally, if you are looking for sessions for your local user group and would like me to present it then please get in touch by leaving a comment below.

 

Download the Tips for Real-World SharePoint Development presentation.

The code will be available shortly in my GitHub repository.