"CORS" dashboard issue.

Hello! I am currently unsure what Is going wrong in my piece of code, I am hosting the dashboard on glitch.com, and I am currently unsure what the "CORS" issue means, all I can provide is the HTML code, and the Console error I get whenever I do actually authorize my Oauth2 app with my website. (Sorry if I did this in the wrong category/channel.)
HAD TO SPLIT THE MESSAGE IN TWO DUE TO THE CHARACTER LIMIT!
HAD TO SPLIT THE MESSAGE IN TWO DUE TO THE CHARACTER LIMIT!
No description
6 Replies
czypher_
czypher_OP5mo ago
Sorce Codes: / images Dashboard.HTML
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/">
<link rel="stylesheet" type="text/css" href="output.css" >
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div class="flex items-center justify-center h-screen bg-discord-gray text-white flex-col">
<div class="text-2xl">Welcome to the dashboard,</div>
<div class="text-4xl mt-3 flex items-center font-medium" >
<img src='' id="avatar" class="rounded-full w-12 h-12 mr-3"/>
<div id="name"></div>
</div>
<a href="/" class="text-sm mt-5">Logout</a>
</div>


<script>

window.onload = () => {
const fragment = new URLSearchParams(window.location.hash.slice(1));
const [accessToken, tokenType] = [fragment.get('access_token'), fragment.get('token_type')];

if (!accessToken) {
window.location.href('/')
return (document.getElementById('login').style.display = 'block');
}

fetch('https://discord.com/api/users/@me', {
headers: {
authorization: `${tokenType} ${accessToken}`,
},

})
.then(result => result.json())
.then(response => {


const { username, discriminator, avatar, id} = response;
//set the welcome username string
document.getElementById('name').innerText = ` ${username}#${discriminator}`;

//set the avatar image by constructing a url to access discord's cdn
document.getElementById("avatar").src = `https://cdn.discordapp.com/avatars/${id}/${avatar}.jpg`;

})
.catch(console.error);

};

</script>


</body>
</html>
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/">
<link rel="stylesheet" type="text/css" href="output.css" >
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.1.1/css/all.min.css" integrity="sha512-KfkfwYDsLkIlwQp6LFnl8zNdLGxu9YAA1QvwINks4PhcElQSvqcyVLLD9aMhXd13uQjoXtEKNosOWaZqXgel0g==" crossorigin="anonymous" referrerpolicy="no-referrer" />
</head>
<body>
<div class="flex items-center justify-center h-screen bg-discord-gray text-white flex-col">
<div class="text-2xl">Welcome to the dashboard,</div>
<div class="text-4xl mt-3 flex items-center font-medium" >
<img src='' id="avatar" class="rounded-full w-12 h-12 mr-3"/>
<div id="name"></div>
</div>
<a href="/" class="text-sm mt-5">Logout</a>
</div>


<script>

window.onload = () => {
const fragment = new URLSearchParams(window.location.hash.slice(1));
const [accessToken, tokenType] = [fragment.get('access_token'), fragment.get('token_type')];

if (!accessToken) {
window.location.href('/')
return (document.getElementById('login').style.display = 'block');
}

fetch('https://discord.com/api/users/@me', {
headers: {
authorization: `${tokenType} ${accessToken}`,
},

})
.then(result => result.json())
.then(response => {


const { username, discriminator, avatar, id} = response;
//set the welcome username string
document.getElementById('name').innerText = ` ${username}#${discriminator}`;

//set the avatar image by constructing a url to access discord's cdn
document.getElementById("avatar").src = `https://cdn.discordapp.com/avatars/${id}/${avatar}.jpg`;

})
.catch(console.error);

};

</script>


</body>
</html>
Picture of error(s):
d.js toolkit
d.js toolkit5mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by staff
treble/luna
treble/luna5mo ago
not djs related, #other-js-ts
czypher_
czypher_OP5mo ago
Alrighty, do I just post the samemessage in there.
treble/luna
treble/luna5mo ago
yes
czypher_
czypher_OP5mo ago
Alright.
Want results from more Discord servers?
Add your server