这可能与缓存有关。您可以尝试将以下代码添加到nuxt.config.js中来禁用缓存:
build: {
extend(config, ctx) {
if (ctx.isClient) {
config.headers = {
"Cache-Control": "no-cache, no-store, must-revalidate",
Pragma: "no-cache",
Expires: 0
};
}
}
}
此外,您还可以尝试使用aws-sdk中的getObject方法来获取S3对象,以确保每次都获取最新的内容:
import AWS from "aws-sdk";
const s3 = new AWS.S3();
async function fetchS3Item(key) {
const params = {
Bucket: "your-bucket-name",
Key: key
};
const response = await s3.getObject(params).promise();
const item = response.Body.toString("utf-8");
return item;
}