[英]Serve static files in Express from AWS S3 bucket
I have a requirement in which static files(CSS,JS files) are copied to a private AWS S3 location and I need to serve those static files in my Express application from that AWS S3 location.我需要将 static 个文件(CSS、JS 文件)复制到私有 AWS S3 位置,我需要从该 AWS S3 位置在我的 Express 应用程序中提供这些 static 个文件。
I tried using https://www.npmjs.com/package/http-proxy-middleware , for this use-case.对于这个用例,我尝试使用https://www.npmjs.com/package/http-proxy-middleware 。
Sample code below:示例代码如下:
import { createProxyMiddleware } from 'http-proxy-middleware';
const app = express();
app.use(
'/static',
createProxyMiddleware({
target: s3 location url,
changeOrigin: true,
})
);
app.listen(3000);
Somehow its failing, Is there a better way to do it, or I am missing something here?不知何故它失败了,有没有更好的方法,或者我在这里遗漏了什么?
To directly proxy it from your node.js app, you'll have to make the bucket in publicly accessible mode if it is in private mode要直接从您的 node.js 应用代理它,如果它处于私有模式,您必须将存储桶设置为公开访问模式
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.