moleculerjs / moleculer-web

:earth_africa: Official API Gateway service for Moleculer framework
http://moleculer.services/docs/moleculer-web.html
MIT License
291 stars 118 forks source link

Accessing CORS settings from env #207

Closed intech closed 3 years ago

intech commented 3 years ago

I propose to discuss adding such a possibility.

The first argument in favor of adding settings via environment variables is to move away from the anti-pattern of using url in the code. A fairly dynamic change to origin, it is logical to leave the rest of the settings static.

Second argument for the convenience of separating environments development: CORS=* production: CORS=url1,url2 (separated by commas)

@icebob It is necessary to define the namespace for the moleculer-web by analogy with MOL__ for the moleculer

icebob commented 3 years ago

Why not use simply:

settings: {
    cors: {
        origin: process.env.CORS_ORIGIN || "*", 
    }
}
intech commented 3 years ago

Can, so the MOL_ settings can be changed :)