I have this POST
request:
const requestOptions = {
method: 'POST',
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
body: JSON.stringify({
grant_type: "password",
client_id: "client",
client_secret: "clientsecret",
username: "matias@gmail.com",
password: "12341234"
})
};
const token = fetch("http://localhost:3000/connect/token", requestOptions)
.then(response => console.log(response))
.catch(error => console.log(error));
I would like to rewrite it so I can bypass CORS error in development environment. To achieve this, I have this code in my next.config.js
file:
const nextConfig = {
reactStrictMode: false,
async rewrites() {
return process.env.NODE_ENV === "development"
? [
{
source: "/connect/token",
destination: "http://localhost:4446/connect/token",
}
]
: [];
},
}
How can I specify the body params ( grant_type
, client_id
, client_secret
, username
and password
) to this Next.js rewrite? The error I am getting suggest these values are not present in my rewrite:
fail: IdentityServer4.Validation.ClientSecretValidator[0]
No client identifier found
I don't know about Next.js, but have you tried to add the url to the client configuration as Allowed Cors Origins ?
You could add in your develop client the url http://localhost:3000
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.