Skip to content

Blazor App HttpClient can't fetch due to being blocked by CORS #22988

Answered by ricksparx
sassy224 asked this question in General
Discussion options

You must be logged in to vote

Hi @javiercn ,below is my code where i am setting the default browser as CORS but still getting the same error.
Could you please give us your working code repo.
builder.Services.AddTransient(sp => new HttpClient(new DefaultBrowserOptionsMessageHandler(new WebAssemblyHttpHandler())
{
//DefaultBrowserRequestCache = BrowserRequestCache.NoStore,
//DefaultBrowserRequestCredentials = BrowserRequestCredentials.Omit,
DefaultBrowserRequestMode = BrowserRequestMode.Cors,
})
{
BaseAddress = new Uri(builder.HostEnvironment.BaseAddress),
});

Replies: 8 comments 10 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@javiercn
Comment options

@dwbidan
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
2 replies
@eXapppk
Comment options

@yogyogi
Comment options

Comment options

You must be logged in to vote
3 replies
@javiercn
Comment options

@ricksparx
Comment options

@eXapppk
Comment options

Answer selected by javiercn
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
3 replies
@javiercn
Comment options

@paulomorgado
Comment options

@javiercn
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area-blazor Includes: Blazor, Razor Components
10 participants
Converted from issue

This discussion was converted from issue #22988 on June 16, 2020 06:35.