Protocol modif
This commit is contained in:
parent
7647bcd52a
commit
830b60dad0
3 changed files with 9 additions and 3 deletions
2
app.js
2
app.js
|
|
@ -93,7 +93,7 @@ async function start() {
|
|||
try {
|
||||
await app.ready();
|
||||
app.swagger();
|
||||
await app.listen({ port: 3000, host: 'localhost' });
|
||||
await app.listen({ port: 3000, host: '0.0.0.0' });
|
||||
app.log.info('Server listening on http://localhost:3000');
|
||||
} catch (err) {
|
||||
app.log.error(err);
|
||||
|
|
|
|||
|
|
@ -3,9 +3,12 @@ const db = require('./db');
|
|||
|
||||
const BOT_ID = "1410578978712060024";
|
||||
const BOT_SECRET = "vhk6jp_jYjvShOqpI8MJ2Efjjm_9Cmyi";
|
||||
const REDIRECT_URI = "http://localhost:3000/auth/discord/callback";
|
||||
|
||||
exports.handleDiscordAuth = async (request, reply) => {
|
||||
const protocol = request.protocol || (request.headers['x-forwarded-proto'] || '').split(',')[0] || 'http';
|
||||
const host = request.hostname || request.headers.host;
|
||||
const REDIRECT_URI = `${protocol}://${host}/auth/discord/callback`;
|
||||
|
||||
const code = request.query.code;
|
||||
if (!code) return reply.code(400).send({ error: "Code de validation manquant" });
|
||||
try {
|
||||
|
|
|
|||
|
|
@ -10,8 +10,11 @@ module.exports = async function (app, opts) {
|
|||
|
||||
// --- Auth Discord ---
|
||||
app.get('/auth/discord', async (req, reply) => {
|
||||
const protocol = req.protocol || (req.headers['x-forwarded-proto'] || '').split(',')[0] || 'http';
|
||||
const host = req.hostname || req.headers.host;
|
||||
const redirectUri = `${protocol}://${host}/auth/discord/callback`;
|
||||
|
||||
const clientId = '1410578978712060024';
|
||||
const redirectUri = 'http://localhost:3000/auth/discord/callback';
|
||||
const scope = 'identify email';
|
||||
const discordAuthUrl = `https://discord.com/api/oauth2/authorize?client_id=${clientId}&redirect_uri=${encodeURIComponent(redirectUri)}&response_type=code&scope=${scope}`;
|
||||
reply.redirect(discordAuthUrl);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue