fix: oauth headers

This commit is contained in:
Mar0xy 2023-09-24 23:01:46 +02:00
parent ce42cc0e8d
commit 30cc0a9b18
No known key found for this signature in database
GPG key ID: 56569BBE47D2C828
2 changed files with 15 additions and 1 deletions

View file

@ -48,7 +48,7 @@ export class MastodonApiServerService {
fastify.addContentTypeParser(['application/x-www-form-urlencoded'], { parseAs: 'string' }, (req, body, done) => {
const dataObj: any = {};
const parsedData = new URLSearchParams(body as string);
for (let pair of parsedData.entries()) {
for (const pair of parsedData.entries()) {
dataObj[pair[0]] = pair[1];
}
done(null, dataObj);

View file

@ -37,6 +37,20 @@ export class OAuth2ProviderService {
});
}); */
fastify.addHook('onRequest', (request, reply, done) => {
reply.header('Access-Control-Allow-Origin', '*');
done();
});
fastify.addContentTypeParser(['application/x-www-form-urlencoded'], { parseAs: 'string' }, (req, body, done) => {
const dataObj: any = {};
const parsedData = new URLSearchParams(body as string);
for (const pair of parsedData.entries()) {
dataObj[pair[0]] = pair[1];
}
done(null, dataObj);
});
fastify.get('/oauth/authorize', async (request, reply) => {
const query: any = request.query;
let param = "mastodon=true";