mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-11 14:20:29 +01:00
CORS error trying to consume __admin/mappings #396
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @devmariodiaz on GitHub (Jan 5, 2022).
Hello Stef,
Happy new year and hoping that you are doing well.
I'm trying to consume __admin/mappings to create new mappings using the method/verb POST and an application developed on React, but I'm getting an error when I send any request. CORS error.
Any clue what I can do to resolve that?
@StefH commented on GitHub (Jan 6, 2022):
Hello @devmariodiaz,
CORS support is not enabled by default, you can enable it yourself when configuring WireMock Server, like:
See also https://github.com/WireMock-Net/WireMock.Net/blob/cors/examples/WireMock.Net.StandAlone.NETCoreApp/Program.cs#L38
@devmariodiaz commented on GitHub (Jan 6, 2022):
Thank you, Stef for your quick answer.
I tried to apply this configuration that you provided, but, it's still sending me the same error related to the CORS error.
We are using our app as a Standalone and as a Service, may be this be the problem?
@StefH commented on GitHub (Jan 6, 2022):
I forgot some code.
You need to use the same policy-name:
This works for me:

https://www.w3schools.com/xml/tryit.asp?filename=tryajax_get2
-->
calling

__amdin/mappingsalso works fine:@devmariodiaz commented on GitHub (Jan 6, 2022):
Thanks a lot for your help, Stef,
Now is working fine for me.
@StefH commented on GitHub (Jan 6, 2022):
https://github.com/WireMock-Net/WireMock.Net/wiki/Cors
@StefH commented on GitHub (Jan 12, 2022):
@devmariodiaz
I decided to add Cors support in WireMock.Net server by using a setting
CorsPolicyOptions.Can you try preview (1.4.31-ci-15770) ?
@devmariodiaz commented on GitHub (Jan 12, 2022):
Thanks a lot Stef,
I will test this preview ASAP, I believe this is a great decision.
@StefH commented on GitHub (Jan 15, 2022):
@devmariodiaz
Did you have time to verify?
@StefH commented on GitHub (Jan 24, 2022):
https://github.com/WireMock-Net/WireMock.Net/pull/714