Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .env.development.example
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ GITHUB_CLIENT_SECRET=your_github_oauth_client_secret
GITHUB_AUTH_ISSUER=https://your_unique_authentication_issuer
JWT_PRIVATE_KEY_PATH=./private-key.pem
JWT_PUBLIC_KEY_PATH=./public-key.pem
JWT_KEY_ID=your-api-key-1
JWT_KEY_ID=your-api-key-1
CORS_ORIGIN=
3 changes: 2 additions & 1 deletion .env.production.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ GITHUB_CLIENT_ID=your_github_oauth_client_id
GITHUB_CLIENT_SECRET=your_github_oauth_client_secret
GITHUB_AUTH_ISSUER=https://your_unique_authentication_issuer
COOKIE_DOMAIN=.yourdomain.com
COOKIE_SAME_SITE=lax
COOKIE_SAME_SITE=lax
CORS_ORIGIN=
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ GITHUB_AUTH_ISSUER=https://your-domain.com/auth/github
> [!NOTE]
> The issuer must be unique for the service. The authentication modules use it to distinguish the providers.

3. (Optional) Configure cookie settings for cross-subdomain support in `.env.production`:
3. (Optional) Configure CORS and cookie settings in `.env.production`:

```bash
CORS_ORIGIN=https://yourapp.yourdomain.com
COOKIE_DOMAIN=.yourdomain.com
COOKIE_SAME_SITE=lax
```
Expand Down
2 changes: 1 addition & 1 deletion bunfig.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[test]
preload = ["./test-setup.ts"]
preload = ["./test-setup.ts"]
8 changes: 7 additions & 1 deletion src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ import { exchangePrice, ExchangePriceSchema } from './handlers/exchange/price';

const { version: appVersion, name: appName, description: appDescription } = packageJson;

const corsOrigin = process.env.CORS_ORIGIN;

export const app = new Elysia()
.error({
FetchApiError,
Expand Down Expand Up @@ -44,7 +46,11 @@ export const app = new Elysia()
}
})
)
.use(cors())
.use(
cors({
...(corsOrigin !== undefined && { origin: corsOrigin })
})
)
.decorate('github', new GitHubDecorator())
.decorate('jwt', new JwtDecorator())
.decorate('exchange', new ExchangeDecorator())
Expand Down
Loading