Skip to content

Commit

Permalink
Merge pull request #290 from The-DevBlog/fix
Browse files Browse the repository at this point in the history
fix
  • Loading branch information
The-DevBlog authored Jul 30, 2024
2 parents 2059d3a + 1fb7505 commit 5ffd5ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
1 change: 1 addition & 0 deletions client/src/pages/post_add.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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());
Expand Down
17 changes: 7 additions & 10 deletions server/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<string[]>();
options.AddPolicy("AllowSpecificOrigin", b => b.WithOrigins(allowedOrigins)
.AllowAnyHeader()
.AllowAnyMethod());
});

// --------------------- SWAGGER ----------------------------------
Expand Down Expand Up @@ -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())
Expand All @@ -119,9 +119,6 @@ public static void Main(string[] args)
app.UseSwaggerUI();
}

// ------------------- MIDDLEWARE -------------------------------
app.UseCors("AllowSpecificOrigin");

// ----------------------- ROUTING -------------------------------
app.UseHttpsRedirection();
app.UseRouting();
Expand Down

0 comments on commit 5ffd5ad

Please sign in to comment.