Note: This article is only relevant for Wix-managed headless projects.
This article explains how to implement a Wix login page using the CLI.
To log in or sign up a member, redirect the browser to the following URL: /api/auth/login. For example:
This redirects the browser to the Wix login page, where Wix handles the login process.
You can specify the URL to redirect to after the login process using a returnUrl query parameter in the initial request. For example, /api/auth/login?returnUrl=/home redirects the browser to /home after the login process. If you don't specify a returnUrl, Wix redirects the browser to the URL that the member was on before you directed them to the login page.
To log out a member, make a POST request to the following URL: /api/auth/logout. For example:
This logs the member out. You can specify the URL to redirect to after the logout process using a returnUrl query parameter in the initial request. For example, /api/auth/logout?returnUrl=/home redirects the browser to /home after the logout process. If you don't specify a returnUrl, Wix redirects the browser to the URL that the member was on before you logged them out.
If you encounter issues with a Wix login page, make sure that the returnUrl query parameter is listed in your allowed authorization redirect URIs, and that the values match exactly. If you provided this URL when you created your Wix-managed headless project, Wix automatically added it to the allowed authorization redirect URIs, but if it's not, you need to add it manually.