Skip to content

Commit

Permalink
fix: s3 config
Browse files Browse the repository at this point in the history
Signed-off-by: Innei <i@innei.in>
  • Loading branch information
Innei committed Apr 23, 2024
1 parent 810deb4 commit 185b5d5
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 9 deletions.
8 changes: 8 additions & 0 deletions src/app.static.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,11 @@ export const appStaticConfig = {

export const CDN_HOST = 'cdn.innei.ren'
export const TENCENT_CDN_DOMAIN = CDN_HOST

export const s3Config = {
accessKeyId: process.env.S3_ACCESS_KEY as string,
secretAccessKey: process.env.S3_SECRET_KEY as string,
bucket: 'uploads',
customDomain: 'https://object.innei.in',
endpoint: `https://de7ecb0eaa0a328071255d557a6adb66.r2.cloudflarestorage.com`,
}
11 changes: 2 additions & 9 deletions src/app/api/s3/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,12 @@ import type { NextRequest } from 'next/server'

import { PutObjectCommand, S3Client } from '@aws-sdk/client-s3'

import { s3Config as config } from '~/app.static.config'
import { apiClient } from '~/lib/request'

const config = {
accountId: 'de7ecb0eaa0a328071255d557a6adb66',
accessKeyId: process.env.S3_ACCESS_KEY as string,
secretAccessKey: process.env.S3_SECRET_KEY as string,
bucket: 'uploads',
customDomain: 'https://object.innei.in',
}

const s3 = new S3Client({
region: 'auto',
endpoint: `https://${config.accountId}.r2.cloudflarestorage.com`,
endpoint: config.endpoint,
credentials: {
accessKeyId: config.accessKeyId,
secretAccessKey: config.secretAccessKey,
Expand Down

0 comments on commit 185b5d5

Please sign in to comment.