Access keys are visible
In my application in Angular 6 I work with two APIs where both need a Key or Token to give permission to the available execution methods.
I created the keys inside src/environmets/environment.prod.ts
.
My angular.json:
"configurations": {
"production": {
"fileReplacements": [
{
"replace": "src/environments/environment.ts",
"with": "src/environments/environment.prod.ts"
}
],
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true
}
}
environment.prod.ts:
export const environment = {
production: false,
hmr: false,
firebase: {
apiKey: 'AIzaSyD8-dfxdfxdfxdf3242342342',
authDomain: 'dfdfd-med.firebaseapp.com',
databaseURL: 'https://ddfdf-med.firebaseio.com',
projectId: 'dxdfdfd-dd',
storageBucket: 'dxxxx-med.appspot.com',
messagingSenderId: '1041058540005'
},
MoipAPI: {
apiKey: 'Basic VTBRTkJWOUVIMFREQjVGM1sssJTFJddddNBV0dVVEdMMFZEMEhPRzZBRE1TS0k0Q1dYQklRT0VWRlJHR0xUQw==',
},
};
In my @Injectable()
service I care
import {environment} from 'environments / environment';
When I do the angular build build with the ng build --prod
command when accessing Developer Tools from Google Chrome in the Sources tab, I can see the keys inside main.435fgfd2cxsss.js
.
This is a problem since my keys are visible to all, they should not be shown in main.435fgfd2cxsss.js
.