-
-
Notifications
You must be signed in to change notification settings - Fork 677
Open
Description
Description
When calling the /api/custom_generate endpoint, the Playwright browser automation gets stuck on the Suno sign-in page instead of loading the create page, causing the CAPTCHA solving process to fail with a timeout error.
Environment
- OS: macOS Silicon
- Node version: v24.12.0
- Deployment: Local development
- Cookie status: Valid (confirmed by successful
/api/get_limitcalls)
Steps to Reproduce
- Set valid
SUNO_COOKIEin.envfile - Verify cookie works by calling
/api/get_limit(succeeds) - Call
/api/custom_generateendpoint with valid parameters - Browser launches but redirects to
https://accounts.suno.com/sign-in?redirect_url=https%3A%2F%2Fsuno.com%2Fcreate
Expected Behavior
Browser should navigate to https://suno.com/create and remain on that page, allowing the CAPTCHA solving flow to proceed.
Actual Behavior
Browser redirects to the sign-in page, preventing access to the create page. The textarea lookup fails because it's on the wrong page:
Found 0 textareas on page- Eventually times out trying to focus on textarea
Logs
{"level":30,"msg":"Navigating to suno.com/create..."}
{"level":30,"msg":"Waiting for page to fully load..."}
{"level":30,"msg":"API response timeout - page might not be fully loaded, continuing anyway"}
{"level":30,"msg":"Triggering the CAPTCHA"}
{"level":30,"msg":"Attempting to close popup with getByLabel..."}
{"level":30,"msg":"getByLabel failed, trying alternative selectors..."}
{"level":30,"msg":"No popup found or unable to close - continuing anyway"}
{"level":30,"msg":"Looking for song description textarea..."}
{"level":30,"msg":"Hip-hop placeholder not found, trying alternative selectors..."}
{"level":30,"msg":"Found 0 textareas on page"}
{"level":30,"msg":"Filling textarea with test prompt..."}
Error generating custom audio: Timeout 30000ms exceeded.
Root Cause Analysis
The issue appears to be related to browser cookie authentication:
- The
SUNO_COOKIEworks for API calls (REST endpoints) - However, when Playwright launches a new browser context, the cookies may not be properly recognized by Suno's frontend
- This causes Suno to redirect to the sign-in page instead of allowing access to
/create
Potential Issues
- Cookie format mismatch: Browser cookies may need different attributes (secure, httpOnly, etc.)
- Session token expiration: The
__sessioncookie might be stale when the browser launches - Cookie domain mismatch: Cookies set for
.suno.commay not work withaccounts.suno.comredirect - Missing cookies: Some required authentication cookies might not be included in the browser context
Relevant Code
The browser launch and cookie setup happens in src/lib/SunoApi.ts:
// Line ~620-640: launchBrowser() method
const cookies = [];
const lax: 'Lax' | 'Strict' | 'None' = 'Lax';
cookies.push({
name: '__session',
value: `${this.currentToken}`,
domain: '.suno.com',
path: '/',
sameSite: lax
});
for (const key in this.cookies) {
cookies.push({
name: key,
value: `${this.cookies[key]}`,
domain: '.suno.com',
path: '/',
sameSite: lax
})
}
await context.addCookies(cookies);Possible Solutions
- Refresh token before browser launch: Call
keepAlive()immediately before launching browser to ensure fresh JWT - Add more cookie attributes: Include
secure: true,httpOnly: falsebased on actual Suno requirements - Handle redirects: Detect the sign-in redirect and retry with refreshed authentication
- Debug cookie state: Log the actual cookies being set and compare with working browser session
- Wait for authentication: Add explicit wait for authenticated state after navigation
Additional Notes
- This may be related to recent Suno frontend changes
- The
CLERK_BASE_URLrecently changed fromhttps://clerk.suno.comtohttps://auth.suno.com - The authentication flow may have additional requirements not captured in the current implementation
Help Wanted
Has anyone else encountered this issue? Any insights on:
- Required cookie attributes for Suno's frontend authentication?
- Changes to Suno's authentication flow?
- Successful workarounds for macOS Silicon specifically?
Metadata
Metadata
Assignees
Labels
No labels