net::ERR_BLOCKED_BY_RESPONSE.NotSameOriginAfterDefaultedToSameOriginByCoep 200
// server.js
app.use((req, res, next) => {
res.header("Cross-Origin-Embedder-Policy", "require-corp");
res.header("Cross-Origin-Opener-Policy", "same-origin");
next();
});
//- header.pug & profile.pug
if loggedInUser.socialOnly
img(src=loggedInUser.avatarUrl, crossorigin).profile-img
~ ~ ~ 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'. GET https://avatars.githubusercontent.com/u/~ ~ ~ net::ERR_FAILED 200
// server.js
app.use((req, res, next) => {
res.header("Cross-Origin-Embedder-Policy", "credentialless");
res.header("Cross-Origin-Opener-Policy", "same-origin");
next();
});
//- header.pug & profile.pug
if loggedInUser.socialOnly
img(src=loggedInUser.avatarUrl, crossorigin="use-credentials").profile-img
- Cross-Origin-Embedder-Policy: credentialless
- img crossorigin
- fetch(url, { mode: "cors" })
ėžë° ëĄę·ļėļė íīë github ëĄę·ļėļė íīë íëĄí ėŽė§ėī ëŠĻë ė ëŽëĪ.
app.use((req, res, next) => {
res.header("Cross-Origin-Embedder-Policy", "credentialless");
res.header("Cross-Origin-Opener-Policy", "same-origin");
next();
});
//- header.pug & profile.pug
if loggedInUser.socialOnly
img(src=loggedInUser.avatarUrl, crossorigin).profile-img
// userController.js
export const finishGithubLogin = async (req, res) => {
// ėĪëĩ
if ("access_token" in tokenRequest) {
const { access_token } = tokenRequest;
const apiUrl = "https://api.github.com";
const userData = await (
await fetch(`${apiUrl}/user`, {
mode: "cors", // ėķę° â
headers: {
Authorization: `token ${access_token}`,
},
})
).json();
// ėĪëĩ
};
ęĩė°Ļ ėķėē ëĶŽėėĪ ęģĩė (CORS)
Making your website "cross-origin isolated" using COOP and COEP
Load cross-origin resources without CORP headers using COEP: credentialless
ëí ę° ė ëĻđėë ėëŽëĨž ęē°ęĩ íīęē°íė§ë§ ęļ°ėĻëģīëĻ íëŽīíĻėī ë í° ęą° ę°ëĪ.
ė§ė§ ëģė ëģ ęąļ ëĪ ė°ūėė íīëīĪėëë° ęē°ęĩ ėīë ęē íīęē°íëĪë.
credentials true ëŽļė ë allow header ëŽļė ë origin ëŽļė ë ė ëķ ėëėëĪ.
ę·ļëë ė§ëŽļėžëĄ ëĻęēĻëė§ ėęģ ęē°ęĩ íīęē°íīė íë ĻíëĪ.
ę·ļ ë°ė ėĪë ė°ļęģ íë(ė―ė§íë) ėëĢëĪ
Contents-Type Header ė Accept Headerė ė°Ļėīė
Reason: Credential is not supported if the CORS header âAccess-Control-Allow-Originâ is â*â
MDN - XMLHttpRequest
Using XMLHttpRequest