When you build with Wix's Astro integration, it provides built-in /api/auth/login and /api/auth/logout endpoints that handle the entire login flow. Just link to these endpoints and Wix takes care of redirecting to the Wix login page, exchanging tokens, and managing the authenticated session.
Note: These built-in endpoints come with Wix's Astro integration. With any other framework, you redirect members to the Wix login page yourself, the same as in self-managed headless.
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 returnToUrl query parameter in the initial request. For example, /api/auth/login?returnToUrl=/home redirects the browser to /home after the login process. If you don't specify a returnToUrl, Wix redirects the browser to your site's home 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 returnToUrl query parameter in the initial request. For example, /api/auth/logout?returnToUrl=/home redirects the browser to /home after the logout process. If you don't specify a returnToUrl, Wix redirects the browser to your site's home page (/).
If you encounter issues with a Wix login page, make sure that:
returnToUrl 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.Last updated: 22 July 2026