Skip to content

Commit

Permalink
build: Modify the rewrite judgment condition
Browse files Browse the repository at this point in the history
  • Loading branch information
Amery2010 committed Jan 3, 2025
1 parent 2a79079 commit 7b3b1f2
Showing 1 changed file with 49 additions and 50 deletions.
99 changes: 49 additions & 50 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,56 +24,55 @@ module.exports = async (phase) => {

if (mode !== 'export') {
nextConfig.rewrites = async () => {
const beforeFilesConfig =
mode === 'standalone'
? [
{
source: '/api/google/upload/v1beta/files',
has: [
{
type: 'query',
key: 'key',
value: '(?<key>.*)',
},
],
destination: '/api/upload/files',
},
{
source: '/api/google/v1beta/files/:id',
has: [
{
type: 'query',
key: 'key',
value: '(?<key>.*)',
},
],
destination: '/api/upload/files?id=:id',
},
]
: [
{
source: '/api/google/upload/v1beta/files',
has: [
{
type: 'query',
key: 'key',
value: '(?<key>.*)',
},
],
destination: `${uploadProxyUrl}/upload/v1beta/files?key=${geminiApiKey}`,
},
{
source: '/api/google/v1beta/files/:id',
has: [
{
type: 'query',
key: 'key',
value: '(?<key>.*)',
},
],
destination: `${uploadProxyUrl}/v1beta/files/:id?key=${geminiApiKey}`,
},
]
const beforeFilesConfig = geminiApiKey
? [
{
source: '/api/google/upload/v1beta/files',
has: [
{
type: 'query',
key: 'key',
value: '(?<key>.*)',
},
],
destination: `${uploadProxyUrl}/upload/v1beta/files?key=${geminiApiKey}`,
},
{
source: '/api/google/v1beta/files/:id',
has: [
{
type: 'query',
key: 'key',
value: '(?<key>.*)',
},
],
destination: `${uploadProxyUrl}/v1beta/files/:id?key=${geminiApiKey}`,
},
]
: [
{
source: '/api/google/upload/v1beta/files',
has: [
{
type: 'query',
key: 'key',
value: '(?<key>.*)',
},
],
destination: '/api/upload/files',
},
{
source: '/api/google/v1beta/files/:id',
has: [
{
type: 'query',
key: 'key',
value: '(?<key>.*)',
},
],
destination: '/api/upload/files?id=:id',
},
]
return {
beforeFiles: [
{
Expand Down

0 comments on commit 7b3b1f2

Please sign in to comment.