Initial commit
This commit is contained in:
7
apps/auth-proxy/.env.example
Normal file
7
apps/auth-proxy/.env.example
Normal file
@@ -0,0 +1,7 @@
|
||||
|
||||
AUTH_SECRET=""
|
||||
AUTH_DISCORD_ID=""
|
||||
AUTH_DISCORD_SECRET=""
|
||||
AUTH_REDIRECT_PROXY_URL=""
|
||||
|
||||
NITRO_PRESET="vercel_edge"
|
||||
16
apps/auth-proxy/README.md
Normal file
16
apps/auth-proxy/README.md
Normal file
@@ -0,0 +1,16 @@
|
||||
# Auth Proxy
|
||||
|
||||
This is a simple proxy server that enables OAuth authentication for preview environments.
|
||||
|
||||
## Setup
|
||||
|
||||
Deploy it somewhere (Vercel is a one-click, zero-config option) and set the following environment variables:
|
||||
|
||||
- `AUTH_DISCORD_ID` - The Discord OAuth client ID
|
||||
- `AUTH_DISCORD_SECRET` - The Discord OAuth client secret
|
||||
- `AUTH_REDIRECT_PROXY_URL` - The URL of this proxy server
|
||||
- `AUTH_SECRET` - Your secret
|
||||
|
||||
Make sure the `AUTH_SECRET` and `AUTH_REDIRECT_PROXY_URL` match the values set for the main application's deployment for preview environments, and that you're using the same OAuth credentials for the proxy and the application's preview environment. The lines below shows what values should match eachother in both deployments.
|
||||
|
||||

|
||||
33
apps/auth-proxy/package.json
Normal file
33
apps/auth-proxy/package.json
Normal file
@@ -0,0 +1,33 @@
|
||||
{
|
||||
"name": "@acme/auth-proxy",
|
||||
"private": true,
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"build": "nitro build",
|
||||
"clean": "rm -rf .turbo node_modules",
|
||||
"dev": "nitro dev --port 3001",
|
||||
"lint": "eslint .",
|
||||
"format": "prettier --check . --ignore-path ../../.gitignore",
|
||||
"typecheck": "tsc --noEmit"
|
||||
},
|
||||
"dependencies": {
|
||||
"@auth/core": "^0.18.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@acme/eslint-config": "workspace:^0.2.0",
|
||||
"@acme/prettier-config": "workspace:^0.1.0",
|
||||
"@acme/tailwind-config": "workspace:^0.1.0",
|
||||
"@acme/tsconfig": "workspace:^0.1.0",
|
||||
"eslint": "^8.53.0",
|
||||
"nitropack": "^2.8.1",
|
||||
"prettier": "^3.1.0",
|
||||
"typescript": "^5.3.3"
|
||||
},
|
||||
"eslintConfig": {
|
||||
"root": true,
|
||||
"extends": [
|
||||
"@acme/eslint-config/base"
|
||||
]
|
||||
},
|
||||
"prettier": "@acme/prettier-config"
|
||||
}
|
||||
17
apps/auth-proxy/routes/[...auth].ts
Normal file
17
apps/auth-proxy/routes/[...auth].ts
Normal file
@@ -0,0 +1,17 @@
|
||||
import { Auth } from "@auth/core";
|
||||
import Discord from "@auth/core/providers/discord";
|
||||
import { eventHandler, toWebRequest } from "h3";
|
||||
|
||||
export default eventHandler(async (event) =>
|
||||
Auth(toWebRequest(event), {
|
||||
secret: process.env.AUTH_SECRET,
|
||||
trustHost: !!process.env.VERCEL,
|
||||
redirectProxyUrl: process.env.AUTH_REDIRECT_PROXY_URL,
|
||||
providers: [
|
||||
Discord({
|
||||
clientId: process.env.AUTH_DISCORD_ID,
|
||||
clientSecret: process.env.AUTH_DISCORD_SECRET,
|
||||
}),
|
||||
],
|
||||
}),
|
||||
);
|
||||
4
apps/auth-proxy/tsconfig.json
Normal file
4
apps/auth-proxy/tsconfig.json
Normal file
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"extends": "@acme/tsconfig/base.json",
|
||||
"include": ["routes"]
|
||||
}
|
||||
Reference in New Issue
Block a user