添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

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:

  • CORS : You need to set up CORS properly to make sure your server accepts requests from your app.
  • Authentication : You need to check that requests to your server are coming from your app and not a malicious user.
  • Multiple instances : You can optionally differentiate between the multiple instances of your app when they make requests to the server.
  • Call Wix APIs : You can call Wix APIs from your backend using the Wix REST API . You need to authenticate your requests using either OAuth or API keys .
  • 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.

    Copy
    1

    To enable local development, you also need to allow CORS requests from localhost:5173 or, preferably, from all origins with localhost.

    Copy
    1