Simplify your stack and build anything. Or everything.
Build tomorrow’s web with a modern solution you truly own.
Code-based nature means you can build on top of it to power anything.
It’s time to take back your content infrastructure.

Simplified Authentication for Headless CMS: Unlocking Reusability in One Line

Simplified Authentication for Headless CMS
Simplified Authentication for Headless CMS
Unlike other headless CMS platforms, Payload offers reusable authentication, saving you time and eliminating the need for separate providers.



1
try {
2
const req = await fetch(`{cms-url}/api/{user-collection}/login`, {
3
method: "POST",
4
credentials: "include",
5
headers: {
6
"Content-Type": "application/json",
7
},
8
body: JSON.stringify({
9
email: "dev@payloadcms.com",
10
password: "password"
11
}),
12
});
13
const data = await req.json();
14
} catch (err) {
15
console.log(err);
16
}
1
try {
2
const req = await fetch('{cms-url}/api/{user-collection}/me', {
3
method: "GET",
4
credentials: "include",
5
headers: {
6
"Content-Type": "application/json"
7
}
8
});
9
const data = await req.json();
10
} catch (err) {
11
console.log(err);
12
}
1
const request = await fetch("http://localhost:3000/api/pages", {
2
headers: {
3
Authorization: `${User.slug} API-Key ${YOUR_API_KEY}`,
4
},
5
});