admin管理员组文章数量:1025208
Im on production trying to use google auth 2.0 with passport on my express js backend.
origin: function(origin, callback) {
if (!origin || allowedOrigins.includes(origin)) {
callback(null, origin); // Return the specific origin, not a wildcard
} else {
callback(new Error('Not allowed by CORS policy'));
}
},
credentials: true,
methods: ['GET', 'POST', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'Accept'],
exposedHeaders: ['Set-Cookie']
}));
on my protected route (frontend) I fetch check-auth
credentials: 'include',
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
}); ````
and I get a cors error ```Access to fetch at '' from origin '' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.```
pulled my hair for 12 hours now ! nothing worked
login logic: I git api/v1/auth - > backend redirects to google -> callback url is dashboard that is a protected route and on protected route we check-auth
Thank you for your help :)
Im on production trying to use google auth 2.0 with passport on my express js backend.
origin: function(origin, callback) {
if (!origin || allowedOrigins.includes(origin)) {
callback(null, origin); // Return the specific origin, not a wildcard
} else {
callback(new Error('Not allowed by CORS policy'));
}
},
credentials: true,
methods: ['GET', 'POST', 'OPTIONS'],
allowedHeaders: ['Content-Type', 'Authorization', 'Accept'],
exposedHeaders: ['Set-Cookie']
}));
on my protected route (frontend) I fetch check-auth
credentials: 'include',
method: 'GET',
headers: {
'Content-Type': 'application/json',
},
}); ````
and I get a cors error ```Access to fetch at '' from origin '' has been blocked by CORS policy: The value of the 'Access-Control-Allow-Origin' header in the response must not be the wildcard '*' when the request's credentials mode is 'include'.```
pulled my hair for 12 hours now ! nothing worked
login logic: I git api/v1/auth - > backend redirects to google -> callback url is dashboard that is a protected route and on protected route we check-auth
Thank you for your help :)
本文标签: authenticationAccesing express server for auth2 return cors errorStack Overflow
版权声明:本文标题:authentication - Accesing express server for auth2 return cors error - Stack Overflow 内容由热心网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://it.en369.cn/questions/1745613601a2159152.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论