diff --git a/client/src/pages/post_add.rs b/client/src/pages/post_add.rs index bcdc8f1..384cc17 100644 --- a/client/src/pages/post_add.rs +++ b/client/src/pages/post_add.rs @@ -59,6 +59,7 @@ pub fn add_post() -> Html { let devblog_status = devblog_status.clone(); let hdrs = helpers::create_auth_header(&token); + hdrs.append("Content-Type", "multipart/form-data"); let form_data = FormData::new().unwrap(); let _ = form_data.append_with_str("description", &description); let _ = form_data.append_with_str("postToDiscord", &discord.to_string()); diff --git a/server/Program.cs b/server/Program.cs index 66ca4c2..40ccfd0 100644 --- a/server/Program.cs +++ b/server/Program.cs @@ -22,13 +22,10 @@ public static void Main(string[] args) // --------------------- CORS POLICY ------------------------------ builder.Services.AddCors(options => { - var allowedOrigins = new[] { "https://thedevblog.net", "https://www.thedevblog.net" }; - options.AddPolicy("AllowSpecificOrigin", builder => - { - builder.WithOrigins(allowedOrigins) - .AllowAnyHeader() - .AllowAnyMethod(); - }); + var allowedOrigins = builder.Configuration.GetSection("AllowedOrigins").Get(); + options.AddPolicy("AllowSpecificOrigin", b => b.WithOrigins(allowedOrigins) + .AllowAnyHeader() + .AllowAnyMethod()); }); // --------------------- SWAGGER ---------------------------------- @@ -106,6 +103,9 @@ public static void Main(string[] args) var app = builder.Build(); + // ------------------- MIDDLEWARE ------------------------------- + app.UseCors("AllowSpecificOrigin"); + // Configure the HTTP request pipeline. if (!app.Environment.IsDevelopment()) @@ -119,9 +119,6 @@ public static void Main(string[] args) app.UseSwaggerUI(); } - // ------------------- MIDDLEWARE ------------------------------- - app.UseCors("AllowSpecificOrigin"); - // ----------------------- ROUTING ------------------------------- app.UseHttpsRedirection(); app.UseRouting();