找出 CORS 辅助函数里的 bug

来自 CORS
Node 24 进阶 4分钟 找出 1处问题

找出这段生成的凭证 CORS 辅助函数中的安全缺陷。

JavaScript
function addCors(request, response) {
  const origin = request.headers.origin;
  if (origin) {
    response.setHeader('Access-Control-Allow-Origin', origin);
    response.setHeader('Access-Control-Allow-Credentials', 'true');
  }
}
在试验场中打开
报告错误