I am using react-native and mysql.
firebase is only used for push notifications.
In the backend, i can hide the api key by using .env, but the problem is that the firebase api key is used in the front.
How can I hide the FIREBASE_API_KEY in this case?
Also, do I need to hide the firebase api?
this is my code
const TextInput = ({hideTodoInput}) => {
async function sendmessage() {
const message = {
to: fcmusertoken,
notification: {
title: `${me?.nickname}님이 댓글을 남기셨습니다`,
body: commentText,
sound: 'default',
},
priority: 'high',
};
const FIREBASE_API_KEY = 'firebase api key' //how can i hide this firebase api key?
let headers = new Headers({
'Content-Type': 'application/json',
Authorization: 'key=' + FIREBASE_API_KEY,
});
try {
let response = await fetch('https://fcm.googleapis.com/fcm/send', {
method: 'POST',
headers,
body: JSON.stringify(message),
});
response = await response.json();
} catch (error) {
}
}
return (
<Input
autoFocus={true}
autoCapitalize="none"
autoCorrect={false}
placeholder="댓글달기"
returnKeyType="done"
value={commentText}
onChange={onChangeCommentText}
onSubmitEditing={() => {
onSubmitComment();
hideTodoInput();
}}
/>
);
};
export default TextInput;