TechnitiumSoftware / DnsServer

Technitium DNS Server
https://technitium.com/dns/
GNU General Public License v3.0
4.27k stars 418 forks source link

Added the ability to access the API from other origins. #664

Closed bluegrassiot closed 1 year ago

bluegrassiot commented 1 year ago

Feature Request

I was trying to use the API and ran into the CORS problem. I can only access the API from the same origin as the DNS Server.

I added the following Environment Variable to allow other origins. Environment variable like as follows:

- CORS_ALLOWED_ORIGINS=http://localhost:3000, http://192.168.0.1 #Comma separated list of origins to allow for CORS.

ShreyasZare commented 1 year ago

Thanks for the PR. The DNS server only seeds the initial settings via environment variables on first start and thus the implementation in this PR is not adequate. Will get the feature implemented soon as mentioned in #663.

bluegrassiot commented 1 year ago

Can you explain a little more? I tested it with my setup and it work fine in docker. It can even be changed after the first startup. My guess is that you want this written to the config file from the environment variable so then it is taken only on startup? I guess this is OK, but it would be annoying if I'm trying to debug from my laptop and I want to allow it as an origin just for the dev environment.

ShreyasZare commented 1 year ago

Can you explain a little more? I tested it with my setup and it work fine in docker. It can even be changed after the first startup

The DNS Server is not just available as docker image. It can also be installed directly on Windows or Linux. So, such an implementation does not take care of other types of deployments.

To add such an option, it has to be added in the dns config file where all other options are stored. The environment variables are used only the first time when config is absent to generate the new config file. After that, the environment variables are not used at all and all the options can only be updated from the settings API.

bluegrassiot commented 1 year ago

In that case I can add it to the config file. No need to close my PR.

ShreyasZare commented 1 year ago

In that case I can add it to the config file. No need to close my PR.

There are more things than just the config. The API needs to be updated, the UI too to add the option, then update API docs, etc. Considering all these things, is why I closed it as inadequate.