0

I have a cors policy like this:

builder.Services.AddCors(p => p.AddPolicy("corsapp", builder =>
{
    //builder.WithOrigins("http://localhost:3000").AllowAnyMethod().AllowAnyHeader();  //it's working
    builder.WithOrigins("http://192.168.0.109:8000").AllowAnyMethod().AllowAnyHeader(); //not working
    builder.WithOrigins("http://192.168.0.109:8000","http://192.168.0.109:8000/").AllowAnyMethod().AllowAnyHeader(); //not working
}));

I am trying to post the data from axios.post from react js form, my server and port config is

vite.config.js:

export default defineConfig({
    plugins: [react()],
    server: {
        host: '192.168.0.109',      -- not working
        port: 8000

        //host:'localhost',          --if i change the host and port to localhost & 3000, it works fine
        // port: 3000
    }
})

Axios post command:

axios.post("http://localhost:5220/api/Auth/register", userData)
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Liam neesan
  • 2,282
  • 6
  • 33
  • 72

0 Answers0