Security icon indicating copy to clipboard operation
Security copied to clipboard

Asp.net core web api with JWT throwing No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access

Open anit05 opened this issue 9 years ago • 6 comments

Hi I have implemented JWT in my asp.net core web api. When i try to call url/token from my jquery application, JWT middleware in api works fine as far as checking credentials and generating token. But when it reaches this point await context.Response.WriteAsync(JsonConvert.SerializeObject(response, new JsonSerializerSettings { Formatting = Formatting.Indented }));

it returns to my jquery app with error, No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'null' is therefore not allowed access.

Is there anything i need to do specifically for this. One more thing that my other APIs are working properly apart from /token api.

anit05 avatar May 03 '17 12:05 anit05

@rynowak @blowdart

Tratcher avatar May 03 '17 16:05 Tratcher

How did you start the app? Templates? Which version?

blowdart avatar May 03 '17 16:05 blowdart

I have implemented JWT middleware in my ASP.NET Core Web API. Now from my JS application, i am calling url/token url with username and password . This is the process i have been following .

anit05 avatar May 04 '17 05:05 anit05

@blowdart - can you take another look?

Eilon avatar May 05 '17 21:05 Eilon

OK, so you started with File New Project "ASP.NET Core Web Application", then you choose WebApi?

What's in your ConfigureServices?

blowdart avatar May 05 '17 21:05 blowdart

Closing because there is not enough information to reproduce this problem.

Eilon avatar Jun 22 '17 23:06 Eilon