Integrate Your Own Backend
While building an app, you often need to use your own APIs, employ third-party APIs, and work with a database.
In order to do these things in a secure manner, you need to create your own backend. You can use any server technology you want to create a backend that integrates with your Wix CLI app.
There are a few things you need to keep in mind when implementing your backend:
When making HTTP requests from your app code to your backend, you need to make sure that your backend allows those requests. Your app frontend code is hosted on
the Wix App CDN
. The app is served from its own
wix.run
subdomain. To allow your app frontend code to make HTTP requests to your backend, you need to allow CORS requests from your frontend's domain.
Add the following headers to your backend's HTTP responses to allow CORS requests from your app.
Replace <your-app-id> with your app's ID. You can find it in your app's dashboard in the Wix Developers Center . Also, only allow the HTTP methods that your app requires.
1
To enable local development, you also need to allow CORS requests from localhost:5173
or, preferably, from all origins with localhost
.
Copy1