If you're upgrading from the previous Wix CLI version, this guide helps you migrate your existing HTTP functions to the new Astro endpoints format. The main changes involve updating your file structure and syntax.
To migrate your HTTP functions to Astro endpoints, first update your backend code:
Relocate HTTP function files from src/backend/api/<name>/api.ts to src/pages/api/<name>.ts.
Add the APIRoute type import:
Change method signatures from:
To:
After updating your backend code, update your frontend code to call the new endpoints:
Change from:
To:
This example shows the old HTTP functions syntax used in the previous CLI version, with files located in the src/backend/api/ directory.
This example shows the new Astro endpoints syntax used in the new CLI version, with files located in the src/pages/api/ directory.