My Azure functions are working locally, but not when deployed

Mitchel Sarauer 1 Reputation point
2022-05-04T16:48:53.613+00:00

I have a Static Web App, with Azure functions for a backend. Using local development, I can get the functions to work, but when deployed they return 500 or 404. The functions work locally when I use fetch with localhost:7071 i.e. fetch('https://localhost:7071/api/getName?game=slug') but not with fetch('/api/getName?game=slug').

I'm using a SvelteKit front-end, with the svelte-adapter-azure-swa. I'm really confused because I've gotten other similar applications to work (with React front end).

Azure Functions
Azure Functions
An Azure service that provides an event-driven serverless compute platform.
4,263 questions
Azure Static Web Apps
Azure Static Web Apps
An Azure service that provides streamlined full-stack web app development.
762 questions
{count} votes

1 answer

Sort by: Most helpful
  1. sadomovalex 3,626 Reputation points
    2022-05-17T14:27:13.797+00:00

    what is the full (absolute) url when the following method is called:

    fetch('/api/getName?game=slug')
    

    Does it really point to function app url? Also did you try to trigger it from Azure portal (Function app > Functions > {functionName} > Code + Test > Test/Run)?

    0 comments No comments