From cd1ba7c8f03f71d53cc9fabbfba39151186ea1b2 Mon Sep 17 00:00:00 2001 From: mrjvs Date: Wed, 12 Aug 2026 12:52:50 +0200 Subject: [PATCH] fix: fixed s3 not working --- .docker/docker-compose.yml | 1 + README.md | 69 +++++++++++----------- example.env | 1 + nuxt.config.ts | 1 + server/api/auth/me.get.ts | 3 +- server/routes/account/sso/discourse.get.ts | 2 +- 6 files changed, 41 insertions(+), 36 deletions(-) diff --git a/.docker/docker-compose.yml b/.docker/docker-compose.yml index d69f052..77af2aa 100644 --- a/.docker/docker-compose.yml +++ b/.docker/docker-compose.yml @@ -72,6 +72,7 @@ services: PN_ACT_CONFIG_S3_BUCKET: "pretendo" PN_ACT_CONFIG_S3_ACCESS_KEY: "GK3515373e4c851ebaad366558" PN_ACT_CONFIG_S3_ACCESS_SECRET: "7d37d093435a41f2aab8f13c19ba067d9776c90215f56614adad6ece597dbb34" + PN_ACT_CONFIG_S3_FORCE_PATH_STYLE: "true" PN_ACT_CONFIG_CDN_BASE_URL: "http://localhost:3902/pretendo" PN_ACT_CONFIG_AES_KEY: "1234567812345678123456781234567812345678123456781234567812345678" PN_ACT_CONFIG_GRPC_MASTER_API_KEY_ACCOUNT: "12345678123456781234567812345678" diff --git a/README.md b/README.md index 8de7a6d..bb9a548 100644 --- a/README.md +++ b/README.md @@ -24,40 +24,41 @@ If you'd like to help localize Pretendo Network, you can contribute to the trans The application can be configured with environment variables. `.env` files are available for development. There are no fully required configuration variables, the app can runs minimally without any configuration: -| Feature | Variable | Description | Default | -| ---------------------------- | -------------------------------------- | --------------------------------------------- | -------------------------- | -| Core | `PN_WEBSITE_PUBLIC_BASE_URL` | Base URL of the app | `https://pretendo.network` | -| | `PN_WEBSITE_PUBLIC_COOKIE_SECURE` | Should Secure be enabled for auth cookies | `true` | -| | | | | -| Authentication | `PN_WEBSITE_GRPC_HOST` | Account server GRPC host + port | - | -| | `PN_WEBSITE_GRPC_API_KEY` | Account server GRPC API key | - | -| | `PN_WEBSITE_API_BASE` | Base URL of the account server | `https://api.pretendo.cc` | -| | `PN_WEBSITE_API_BASE_HOST` | Hostname of the account server | `api.pretendo.cc` | -| | | | | -| Progress tracking | `PN_WEBSITE_GITHUB_API_TOKEN` | Github API token | - | -| | | | | -| Discord | `PN_WEBSITE_DISCORD_BOT_TOKEN` | Discord bot token | - | -| | `PN_WEBSITE_DISCORD_CLIENT_ID` | Discord OAuth client ID | - | -| | `PN_WEBSITE_DISCORD_CLIENT_SECRET` | Discord OAuth client secret | - | -| | `PN_WEBSITE_DISCORD_GUILD_ID` | Discord server ID for role linking | - | -| | `PN_WEBSITE_DISCORD_TESTER_ROLE_ID` | Role to give for tester access | (No role) | -| | `PN_WEBSITE_DISCORD_SUPPORTER_ROLE_ID` | Role to give for supporter access | (No role) | -| | | | | -| Payments | `PN_WEBSITE_STRIPE_SECRET_KEY` | Stripe secret key | - | -| (Requires `discord` feature) | `PN_WEBSITE_STRIPE_NOTIFICATION_EMAIL` | Email address to send stripe notifications to | (No notifications) | -| | `PN_WEBSITE_MONGO_CONNECTION_STRING` | MongoDB connection string for account server | - | -| | `PN_WEBSITE_SMTP_HOST` | Host for the SMTP server | - | -| | `PN_WEBSITE_SMTP_PORT` | Port for the SMTP server | `587` | -| | `PN_WEBSITE_SMTP_SECURE` | Use a secure SMTP connection | `true` | -| | `PN_WEBSITE_SMTP_USER` | Username for the SMTP server | (No SMTP auth) | -| | `PN_WEBSITE_SMTP_PASSWORD` | Password for the SMTP server | (No SMTP auth) | -| | `PN_WEBSITE_SMTP_FROM_EMAIL` | Email to sent emails from | - | -| | `PN_WEBSITE_SMTP_FROM_NAME` | Display of the FROM email adress | - | -| | | | | -| Captcha | `PN_WEBSITE_HCAPTCHA_SECRET_KEY` | HCaptcha secret key | - | -| | `PN_WEBSITE_PUBLIC_HCAPTCHA_SITE_KEY` | HCaptcha site key | - | -| | | | | -| Discourse SSO | `PN_WEBSITE_DISCOURSE_SSO_SECRET` | Discourse SSO secret | - | +| Feature | Variable | Description | Default | +| ---------------------------- | -------------------------------------- | --------------------------------------------- | ---------------------------- | +| Core | `PN_WEBSITE_PUBLIC_BASE_URL` | Base URL of the app | `https://pretendo.network` | +| | `PN_WEBSITE_PUBLIC_CDN_BASE_URL` | Base URL for the CDN | `https://r2-cdn.pretendo.cc` | +| | `PN_WEBSITE_PUBLIC_COOKIE_SECURE` | Should Secure be enabled for auth cookies | `true` | +| | | | | +| Authentication | `PN_WEBSITE_GRPC_HOST` | Account server GRPC host + port | - | +| | `PN_WEBSITE_GRPC_API_KEY` | Account server GRPC API key | - | +| | `PN_WEBSITE_API_BASE` | Base URL of the account server | `https://api.pretendo.cc` | +| | `PN_WEBSITE_API_BASE_HOST` | Hostname of the account server | `api.pretendo.cc` | +| | | | | +| Progress tracking | `PN_WEBSITE_GITHUB_API_TOKEN` | Github API token | - | +| | | | | +| Discord | `PN_WEBSITE_DISCORD_BOT_TOKEN` | Discord bot token | - | +| | `PN_WEBSITE_DISCORD_CLIENT_ID` | Discord OAuth client ID | - | +| | `PN_WEBSITE_DISCORD_CLIENT_SECRET` | Discord OAuth client secret | - | +| | `PN_WEBSITE_DISCORD_GUILD_ID` | Discord server ID for role linking | - | +| | `PN_WEBSITE_DISCORD_TESTER_ROLE_ID` | Role to give for tester access | (No role) | +| | `PN_WEBSITE_DISCORD_SUPPORTER_ROLE_ID` | Role to give for supporter access | (No role) | +| | | | | +| Payments | `PN_WEBSITE_STRIPE_SECRET_KEY` | Stripe secret key | - | +| (Requires `discord` feature) | `PN_WEBSITE_STRIPE_NOTIFICATION_EMAIL` | Email address to send stripe notifications to | (No notifications) | +| | `PN_WEBSITE_MONGO_CONNECTION_STRING` | MongoDB connection string for account server | - | +| | `PN_WEBSITE_SMTP_HOST` | Host for the SMTP server | - | +| | `PN_WEBSITE_SMTP_PORT` | Port for the SMTP server | `587` | +| | `PN_WEBSITE_SMTP_SECURE` | Use a secure SMTP connection | `true` | +| | `PN_WEBSITE_SMTP_USER` | Username for the SMTP server | (No SMTP auth) | +| | `PN_WEBSITE_SMTP_PASSWORD` | Password for the SMTP server | (No SMTP auth) | +| | `PN_WEBSITE_SMTP_FROM_EMAIL` | Email to sent emails from | - | +| | `PN_WEBSITE_SMTP_FROM_NAME` | Display of the FROM email adress | - | +| | | | | +| Captcha | `PN_WEBSITE_HCAPTCHA_SECRET_KEY` | HCaptcha secret key | - | +| | `PN_WEBSITE_PUBLIC_HCAPTCHA_SITE_KEY` | HCaptcha site key | - | +| | | | | +| Discourse SSO | `PN_WEBSITE_DISCOURSE_SSO_SECRET` | Discourse SSO secret | - | # Website refactor diff --git a/example.env b/example.env index c46192f..c0e01ff 100644 --- a/example.env +++ b/example.env @@ -2,6 +2,7 @@ # Core PN_WEBSITE_PUBLIC_BASE_URL=http://localhost:3000 +PN_WEBSITE_PUBLIC_CDN_BASE_URL=http://pretendo.localhost:3902 PN_WEBSITE_PUBLIC_COOKIE_SECURE=false # Optional - Authentication diff --git a/nuxt.config.ts b/nuxt.config.ts index d2f3afa..05cff82 100644 --- a/nuxt.config.ts +++ b/nuxt.config.ts @@ -57,6 +57,7 @@ export default defineNuxtConfig({ public: { baseUrl: 'https://pretendo.network', + cdnBaseUrl: 'https://r2-cdn.pretendo.cc', hcaptchaSiteKey: '', cookieSecure: true } diff --git a/server/api/auth/me.get.ts b/server/api/auth/me.get.ts index d6451b4..a96e36d 100644 --- a/server/api/auth/me.get.ts +++ b/server/api/auth/me.get.ts @@ -1,6 +1,7 @@ import type { GetApiAuthMe } from '#shared/api-types'; export default defineEventHandler(async (event): Promise => { + const config = useRuntimeConfig(event); const auth = enforceLoggedIn(event); const grpc = useAccountGrpc(event); @@ -12,7 +13,7 @@ export default defineEventHandler(async (event): Promise => { serverAccessLevel: data.serverAccessLevel as any, mii: data.mii ? { - imageUrl: `https://r2-cdn.pretendo.cc/mii/${data.pid}/normal_face.png`, + imageUrl: `${config.public.cdnBaseUrl}/mii/${data.pid}/normal_face.png`, name: data.mii.name } : null diff --git a/server/routes/account/sso/discourse.get.ts b/server/routes/account/sso/discourse.get.ts index 159572a..8391f18 100644 --- a/server/routes/account/sso/discourse.get.ts +++ b/server/routes/account/sso/discourse.get.ts @@ -53,7 +53,7 @@ export default defineEventHandler(async (event) => { email: `${userData.pid}@invalid.com`, // Don't change, used by other systems username: userData.username, name: userData.username, - avatar_url: `https://r2-cdn.pretendo.cc/mii/${userData.pid}/normal_face.png`, + avatar_url: `${config.public.cdnBaseUrl}/mii/${userData.pid}/normal_face.png`, avatar_force_update: 'true' }); const encodedReturnPayload = Buffer.from(returnPayload.toString()).toString('base64');