Skip to content

Commit

Permalink
Merge pull request #16 from rajnishdargan/asset-upload-proxy
Browse files Browse the repository at this point in the history
Adding Asset Upload Proxy
  • Loading branch information
itsvick authored Oct 8, 2024
2 parents b5093df + b8d6009 commit 802c874
Show file tree
Hide file tree
Showing 6 changed files with 515 additions and 152 deletions.
3 changes: 2 additions & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
BASE_URL="" # Middleware Path - eg : "https://middleware.prathamdigital.org"
AUTH_API_TOKEN="" # User Auth Access Token
TENANT_ID="" # Tenant Id of User
TENANT_ID="" # Tenant Id of User
CLOUD_STORAGE_URL="" #Use environment variable for S3 Cloud Storage URL
24 changes: 18 additions & 6 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,27 @@ const nextConfig = {
esmExternals: false,
},
async rewrites() {
return [
return [
{
source: '/action/:path*', // Match any route starting with /action/
destination: '/api/proxy?path=/action/:path*', // Forward to the proxy API
source: '/action/asset/v1/upload/:identifier*', // Match asset upload routes
destination: '/api/fileUpload', // Forward asset uploads to fileUpload.js
},
{
source: '/api/:path*', // Match any route starting with /api/
destination: '/api/proxy?path=/api/:path*', // Forward to the proxy API
}
source: '/action/asset/:path*', // Match other /action/asset routes
destination: '/api/proxy?path=/action/asset/:path*', // Forward other /action/asset requests to proxy.js
},
{
source: '/action/:path*', // Match any other routes starting with /action/
destination: '/api/proxy?path=/action/:path*', // Forward them to proxy.js
},
{
source: '/api/:path*', // Match /api/ routes
destination: '/api/proxy?path=/api/:path*', // Forward them to proxy.js
},
{
source: '/assets/public/:path*', // Match any URL starting with /assets/public/
destination: `${process.env.CLOUD_STORAGE_URL}/:path*`, // Forward to S3, stripping "/assets/public"
},
];
},
/**
Expand Down
Loading

0 comments on commit 802c874

Please sign in to comment.