access-control-allow-origin: http://localhost:3000
content-length: 299
content-type: application/json; charset=utf-8
date: Mon, 01 May 2023 11:35:51 GMT
etag: W/"12b-8efK5dxnadj10qqm+FsB8wLDLFE"
set-cookie: refreshToken=eyJhbGci0iJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdW
IiOiI1YTk3NzgxZC05ZWQ4LTQxZTItOThhNi03ZmMzNTg0MTNjNTUiLCJpYXQiOjE20 DI5NDA5NTESIMV4CCI6MTY4NDE1MDU1MX0.avIPao2AXowDOKHYG0Ft2WiSg@cASgxZ
ePqaP5xF0sw; Domain=localhost; Path=/; HttpOnly; SameSite=Lax
vary: Origin
x-powered-by: Express
Set-Cookie was blocked because its Domain attribute was invalid with regards to the current host url
server url : https://abcd.site
front url : http://localhost:3000
SameSite=None & secure option need "https". But our front is not yet deployed.
I tried Next.js config setting
/** @type {import('next').NextConfig} */
const nextConfig = {
reactStrictMode: true,
compiler: { emotion: true },
async rewrites() {
return [
{
source: "/:path*",
destination: "https://need-romance.site/:path*",
},
];
},
};
module.exports = nextConfig;
export const login = async (email: string, password: string) => {
try {
const response = await axios({
method: "post",
url: URL + "/auth/login",
data: {
email,
password,
},
withCredentials: true,
headers: {
"Cache-Control": "no-cache",
},
});
return response.data;
} catch (error) {
console.log(error);
}
};
Access to XMLHttpRequest at 'https://need-romance.site/auth/login' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: The 'Access-Control-Allow-Origin' header has a value 'localhost:3000' that is not equal to the supplied origin.
This attempt to set a cookie via a Set-Cookie header was blocked because it had the "SameSite=Lax" attribute but came from a cross-site response which was not the response to a top-level navigation.
There were errors like this, too.
I asked them to search on the Internet, but the error only changed and it was not solved.
I tried removing the credential option, but the error in the yellow triangle disappeared, but the cookie didn't set in.
It was definitely when it was http before.
help me...