【发布时间】:2021-09-01 08:16:10
【问题描述】:
我想从 imgix 缓存中清除图像,他们有一个 API (https://docs.imgix.com/setup/purging-images)
我使用 axios 从我的 nodejs 后端发出请求:
const imgixKey = functions.config().imgix.key;
const headers = {
Authorization: `Bearer ${imgixKey}`,
'Content-Type': 'application/json',
};
const data = JSON.stringify({
type: 'purges',
attributes: {
url: href,
source_id: 'SOsourceId',
},
});
try {
await axios.post('https://api.imgix.com/api/v1/purge', data, { headers });
functions.logger.log('Purged Image successfully' + href);
} catch (e) {
functions.logger.error('Error removing image from cache ' + href + ' -> ' + e);
}
Error removing image from cache {stackoverflowimgpath.png} -> Error: Request failed with status code 400
问题是除了状态码 400 之外没有指定其他内容,我检查了图像路径并尝试了不同的 Content-Type 标头,就像他们的示例中一样,但也没有用。
由于我无法从回复中获得更多信息,因此我在此寻求帮助,因为我不知道如何继续。
【问题讨论】: