> To build or manage a Wix site with an AI agent, follow https://www.wix.com/headless/skill.md
> It builds a new Wix site or puts your own site online, from a prompt, and keeps changing it afterwards. The pages are code in any web technology, and Wix runs the backend.
> It works through the Wix plugin (the Wix MCP and the Wix skills), the Wix CLI or no Wix login, and puts the site live on Wix hosting or on another host.
> Business features include a store, bookings, events and tickets, a restaurant, a blog, forms, members and many more.
> Read the Wix skills online at https://www.wix.com/skills
> 
> Portal Navigation:
> 
> - Append `.md` to any URL under `https://dev.wix.com/docs/` to get its markdown version.
> - Pages are either content pages (article or reference text) or menu pages (a list of links to child pages).
> - To get a menu page, truncate any URL to a parent path and append `.md` (e.g. `https://dev.wix.com/docs/sdk.md`, `https://dev.wix.com/docs/sdk/core-modules.md`).
> - If a reference page seems to be missing its schema (parameters, return types, or type definitions), append `?schema=true` to its `.md` URL (e.g. `https://dev.wix.com/docs/contexts/contexts/stores/category-info/use-category-info-context.md?schema=true`).
> - Top-level index of all portals: https://dev.wix.com/docs/llms.txt
> - Full concatenated docs: https://dev.wix.com/docs/llms-full.txt

## Resource: Add Member Login with the Astro Integration

## Article: Add Member Login with the Astro Integration

## Article Link: https://dev.wix.com/docs/go-headless/authentication/members/wix-login-page/add-member-login-with-the-astro-integration.md

## Article Content:

# Add Member Login with the Astro Integration

When you build with [Wix's Astro integration](https://dev.wix.com/docs/go-headless/wix-managed-headless/about-the-astro-integration.md), 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](https://dev.wix.com/docs/go-headless/authentication/about-authentication.md).

## Log in
To log in or sign up a member, redirect the browser to the following URL: `/api/auth/login`. For example:
```html
<a href="/api/auth/login" class=login-btn">Log In</a>
```

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 (`/`).

## Log out
To log out a member, make a `POST` request to the following URL: `/api/auth/logout`. For example:
```javascript
axios.post('/api/auth/logout')
```

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 (`/`).

## Troubleshooting

If you encounter issues with a Wix login page, make sure that:

- The `returnToUrl` query parameter is listed in your [allowed authorization redirect URIs](https://dev.wix.com/docs/go-headless/authentication/setup/allow-redirect-uris-and-domains.md), 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.
- You haven't set a custom login URL in your OAuth app settings. Wix-managed headless uses Wix's login page automatically, so the **login URL** field should be empty in your [Headless Settings](https://www.wix.com/my-account/site-selector/?buttonText=Select%20Site&title=Select%20a%20Site&autoSelectOnSingleSite=true&actionUrl=https:%2F%2Fwww.wix.com%2Fdashboard%2F%7B%7BmetaSiteId%7D%7D%2Foauth-apps-settings).