Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

.NET backend: CORS headers set by mapservice should be optional #968

Closed
maan002 opened this issue Dec 20, 2021 · 1 comment
Closed

.NET backend: CORS headers set by mapservice should be optional #968

maan002 opened this issue Dec 20, 2021 · 1 comment
Assignees
Labels
difficulty:easy Functionality is considered easy to port module:backend MapService stuff .NET Pull requests that update .net code priority:normal
Milestone

Comments

@maan002
Copy link
Contributor

maan002 commented Dec 20, 2021

Is your feature request related to a problem? Please describe.
The .NET Backend is designed to always set and return CORS headers to the client using C# code. In simple installations this might be what you want. In more advanced installations you really want to do this by installing and using the IIS CORS Module, not by application code.

To get the same functionality using the CORS Module you have to add 3-5 lines in Web.config.

<system.webServer>
  <cors enabled="true">
    <add origin="*" />
  </cors>
</system.webServer>

Example of C# code is found in the AllowCrossSiteJsonAttribute.cs file and the ExportController.cs file, function [HttpOptions] PDF.

There is a risk that headers set by the application will interfer with the headers set by the CORS Module.

Describe the solution you'd like
Add a compiler setting that will remove the CORS code from the .NET Backend if enabled.
The compiler setting should default to keep the CORS code.

Describe alternatives you've considered
Remove the CORS code altogether, but this might break existing installations.

Additional context

@maan002 maan002 self-assigned this Dec 20, 2021
@maan002 maan002 added .NET Pull requests that update .net code difficulty:easy Functionality is considered easy to port module:backend MapService stuff priority:normal labels Dec 20, 2021
@maan002 maan002 modified the milestones: 3.x, 3.9 Dec 20, 2021
@maan002 maan002 changed the title .NET backend: CORS headers set by the application should be optional .NET backend: CORS headers set by mapservice should be optional Dec 20, 2021
@jacobwod
Copy link
Member

jacobwod commented Jan 3, 2022

Looks like #199 that I created and then closed as stale after some time (there was no consensus about it at that time, some people really wanted it to stay the way it works). Here's some abstract from my original issue:

Mapservice should not assume that CORS will be needed. It should be left to the system administrator to decide, and when necessary, CORS headers are easily added in Web.config.

Thumbs up from me, even if we don't use this backend it looks as the correct behaviour (that's how it works in the NodeJS backend too). But make sure to ask the question so everyone gets a saying in this one as it will break existing setups without necessary changes in Web.config.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
difficulty:easy Functionality is considered easy to port module:backend MapService stuff .NET Pull requests that update .net code priority:normal
Projects
None yet
Development

No branches or pull requests

2 participants