Skip to content

Failed to Get Session ID: SUNO_COOKIE Error Persists Despite Correct Setup #223

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
awpalle opened this issue Jan 7, 2025 · 10 comments
Closed

Comments

@awpalle
Copy link

awpalle commented Jan 7, 2025

Describe the bug
I am consistently encountering issues with my Suno cookie when trying to use the Suno API. The API returns the following error:
{"error":"Internal server error. Error: Failed to get session id, you may need to update the SUNO_COOKIE"}
Despite following the instructions to obtain and update the cookie, the issue persists.

To Reproduce
Steps to reproduce the behavior:

Go to app.suno.ai and log in.

Open the browser's developer tools (F12) and navigate to the Network tab.

Refresh the page and locate the request containing client?_clerk_js_version.

Copy the Cookie value from the request headers.

Set the SUNO_COOKIE environment variable in the .env file or Vercel dashboard with the copied cookie value.

Run the Suno API locally or deploy it to Vercel.

Make a request to the /api/get_limit endpoint.

Observe the error: {"error":"Internal server error. Error: Failed to get session id, you may need to update the SUNO_COOKIE"}.

Expected behavior
I expected the API to return my quota information, such as:

json
Copy
{
"credits_left": 50,
"period": "day",
"monthly_limit": 50,
"monthly_usage": 50
}
Instead, I received an error indicating an issue with the session ID or cookie.

Screenshots
If applicable, I can provide screenshots of:

The browser's developer tools showing the cookie extraction process.

The error response from the API.

Desktop

OS: [e.g., Windows 11]

Browser: [e.g., Chrome, Version 118]

Additional context

I have tried logging out and back into app.suno.ai to refresh the cookie, but the issue persists.

I am using the latest version of the suno-api repository, pulled directly from the main branch.

The issue occurs both when running the API locally and when deployed to Vercel.

I have double-checked that the SUNO_COOKIE environment variable is correctly set and matches the cookie value from the browser.

@gohoski
Copy link
Contributor

gohoski commented Jan 8, 2025

Right now use the version from my PR, it's the only working right now. Please note that it is paid to solve the CAPTCHAs. #222

@hedleyroos
Copy link

@gohoski I have the same issue as @awpalle , and I have switched to your PR, but I still get the error. I don't even get to the point where 2captcha is called, so maybe this issue is something else?

@hedleyroos
Copy link

@awpalle I solved my issue. When visiting the get_limit endpoint by browser, it will fail, because the browser provides its own set of default cookies that trumps the cookie set in the environment. Visiting the endpoint with curl works correctly.

Note I'm testing on @gohoski's branch, and I use docker compose.

@gohoski
Copy link
Contributor

gohoski commented Jan 13, 2025

@hedleyroos everything is working fine for me when I'm testing both on swagger and via the API endpoint on Mozilla Firefox and Microsoft Edge… maybe your extensions are adding some unnecessary cookies.

But I will definitely implement a check if the __client cookie exists, if not, then use the cookie from env.

@hedleyroos
Copy link

hedleyroos commented Jan 13, 2025

@gohoski yes, that is a possibility.

FWIW the line that causes the issue is https://github.com/gohoski/suno-api/blob/patch-1/src/lib/SunoApi.ts#L801. This is from your patch branch. Interestingly, main from the official repo does not have this check. It only does https://github.com/gcui-art/suno-api/blob/main/src/lib/SunoApi.ts#L535.

I tested with Firefox and Chrome on Ubuntu, and I do run some extensions. This post is probably more relevant to your branch. I just happened to search for a similar error and found this issue.

Finally, thanks for your branch! It solves a huge headache for everyone.

@Lynn0990
Copy link

I discovered a website that not only supports Suno V4 and API, but also does not have watermarks.
Through this address: https://surl.id/1uHIdUobVg
API: https://surl.id/1uHIdUmZQU
Documentation: https://surl.id/1uHIdUmyFr

@awpalle
Copy link
Author

awpalle commented Jan 21, 2025

@gohoski it's working!

But now i'm stuck with the CAPTCHAs. Does that mean I have to pay for a subscription to solve the issue?

@gohoski
Copy link
Contributor

gohoski commented Jan 21, 2025

@awpalle Did you register on 2Captcha and entered the API key? Also try using a macOS system for avoiding CAPTCHAs, not required though

@awpalle
Copy link
Author

awpalle commented Jan 22, 2025

@gohoski I did, and it's working! It's wonderful. Thank you !!

@gcui-art gcui-art deleted a comment Jan 27, 2025
@gohoski
Copy link
Contributor

gohoski commented Jan 29, 2025

The PR has been merged and this should be fixed now. Please close this issue as completed.

@awpalle awpalle closed this as completed Feb 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants