+
{
const server = useCookie('nuxtodon-server')
const token = useCookie('nuxtodon-token')
+
const masto = login({
- url: server.value || DEFAULT_SERVER,
+ url: `https://${server.value || DEFAULT_SERVER}`,
accessToken: token.value,
})
nuxt.vueApp.provide('masto', masto)
+
+ // Reload the page when the token changes
+ watch(token, () => {
+ location.reload()
+ })
})
diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml
index 77a3185e..90c5cb45 100644
--- a/pnpm-lock.yaml
+++ b/pnpm-lock.yaml
@@ -20,6 +20,7 @@ specifiers:
rollup-plugin-node-polyfills: ^0.2.1
sanitize-html: ^2.7.3
typescript: ^4.8.4
+ ufo: ^1.0.0
devDependencies:
'@antfu/eslint-config': 0.30.1_rmayb2veg2btbq6mbmnyivgasy
@@ -41,6 +42,7 @@ devDependencies:
rollup-plugin-node-polyfills: 0.2.1
sanitize-html: 2.7.3
typescript: 4.8.4
+ ufo: 1.0.0
packages:
@@ -6559,6 +6561,10 @@ packages:
resolution: {integrity: sha512-fk6CmUgwKCfX79EzcDQQpSCMxrHstvbLswFChHS0Vump+kFkw7nJBfTZoC1j0bOGoY9I7R3n2DGek5ajbcYnOw==}
dev: true
+ /ufo/1.0.0:
+ resolution: {integrity: sha512-DRty0ZBNlJ2R59y4mEupJRKLbkLQsc4qtxjpQv78AwEDuBkaUogMc2LkeqW3HddFlw6NwnXYfdThEZOiNgkmmQ==}
+ dev: true
+
/ultrahtml/0.4.0:
resolution: {integrity: sha512-pnJXeIWo9gu7ftQLsMii4Se9kWOzyuH63EDsOsFKwP9XTdLG+QI+JUUxXFSAlCJ/frcdmjfE6kSvvCKiGmiakg==}
dev: true
diff --git a/server/api/[server]/oauth.ts b/server/api/[server]/oauth.ts
new file mode 100644
index 00000000..563e4dc9
--- /dev/null
+++ b/server/api/[server]/oauth.ts
@@ -0,0 +1,21 @@
+import { getQuery } from 'ufo'
+
+export default defineEventHandler(async (event) => {
+ const query = getQuery(event.req.url!)
+ const code = query.code
+ const server = event.context.params.server
+ console.log({ query, server })
+
+ const res = await $fetch(`https://${server}/oauth/token`, {
+ method: 'POST',
+ body: {
+ client_id: 'your_client_id_here',
+ client_secret: 'your_client_secret_here',
+ redirect_uri: 'urn:ietf:wg:oauth:2.0:oob',
+ grant_type: 'authorization_code',
+ code,
+ scope: 'read write follow push',
+ },
+ })
+ console.log({ res })
+})
diff --git a/server/api/pageview.ts b/server/api/pageview.ts
deleted file mode 100644
index e364c580..00000000
--- a/server/api/pageview.ts
+++ /dev/null
@@ -1,7 +0,0 @@
-const startAt = Date.now()
-let count = 0
-
-export default defineEventHandler(() => ({
- pageview: count++,
- startAt,
-}))