I have a javascript file where my database function to fetch records is stored. This code below fetches the records from a specific Odoo model. Example code: RFQListApi.js:
const Odoo = require('odoo-await');
const rootUrl ='exampleURL'
const odoo = new Odoo({
baseUrl: rootUrl,
port: 24,
db: 'test',
username: "test123",
password: "test123"
});
// Exporting to vue file
export default {
async getList (){
await odoo.connect();
// Read data
const records = await odoo.searchRead(`ship.order`, {}, ['name', 'subject']);
return records
}
}
Now I am calling this function by exporting this function to a VueJS file. Something like this:
<template>
<div>
<CRow>
<CCol sm="12">
<CTableWrapper
:items="results"
hover
striped
border
small
fixed
caption="Request for Quotations"
/>
</CCol>
</CRow>
</div>
</template>
<script>
import regeneratorRuntime from "regenerator-runtime";
import CTableWrapper from './RFQsTable.vue'
import RFQsList from './api/RFQsListApi'; // for API calling
export default {
name: 'RFQsList',
components: { CTableWrapper },
data(){
return{
results: [],
values:[]
}
},
created(){
this.getConnected();
},
methods: {
async getConnected(){
RFQsList.getList()
.then((results) =>{
this.$set(this,"results",results) // storing in event data()
})
.catch(e =>console.log(e, "Error from catch"))
},
}
}
</script>
As you can see all the details from the RFQsListApi.js file, such as username and password are visible and anyone can access these files by viewing the source. What can I do to protect or hide these username and other sensitive details from others.
question from:
https://stackoverflow.com/questions/65931466/how-to-prevent-javascript-files-from-showing-in-view-source 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…