I’ll post more info about this later if i need to. I believe this issue will ultimately go away in production but the way I’m developing my app it exists right now. I may be forced to change the way I’m developing. I have my aurelia application which i’m launching using the CLI’s au run. I have my dotnet core 2.1 web api application that I’m launching using dotnet run. Since both of these are running using their own port I needed to enable CORS. That is done with no issue. I have upload code that actually works.
The issue occurs on the aurelia/syncfusion end. When watching the network, I see my requests go out and they are returning 200s, but when watching the console, there is still a cors failure for some reason and that results in a rejected promise. The syncfusion control acts like the file upload actually failed.
The reason I say this should go away in production is because my aurelia application will be hosted on the same server as the API, but development was always meant to be standalone.
Thats not much to go on, can you reproduce this to a particular request? can you share the reason of the rejected promise? Also, can you share your CORS configuration?
Will do when I can, don’t have access to my code at the moment which is why there wasn’t anything in the original. I really don’t think it’s a cors config issue. I have allow my origin and all methods. The upload method on the server does get hit. It’s just about as open as it can be. I am not doing anything special on the client method either.
I’m not going to spend to much time on this as ultimately it won’t be a cors
Thats odd… Would be great if we had a repo. Otherwise, can you share with us the request and response headers of both the POST and the preceding options request?
Seems like the Upload response does not contain an Access-Control-Allow-Origin header. Hence your browser is not interpreting the response (That header needs to be present both on the OPTION response as well as the response of the actual request).
This is a problem in your ASP.NET Core code. Specifically, though your middleware is behaving as it should and is adding the CORS headers to the response, in FileController, you’re calling Response.Clear() after a succesful upload which then removes the CORS headers from the response.