0

I'm Newbie. studying React, and I'm trying to create a project and host it on firebase, but there are the following problems.

I'm using firebase database, and I set firebase hosting to be performed when it becomes the main through github actions.

`const firebaseConfig = {
  apiKey: process.env.REACT_APP_FIREBASE_API_KEY,
  authDomain: process.env.REACT_APP_AUTH_DOMAIN,
  databaseURL: process.env.REACT_APP_DATA_BASE_URL,
  projectId: process.env.REACT_PROJECT_ID,
  appId: process.env.REACT_APP_ID,
  measurementId: process.env.REACT_MEASUREMENT_ID,
};`

firebase.js

`REACT_APP_FIREBASE_API_KEY = "my api key"
REACT_APP_AUTH_DOMAIN = "my auth domain"
REACT_APP_DATA_BASE_URL = "my base url"
REACT_PROJECT_ID = "my project id"
REACT_MEASUREMENT_ID = "my measurement id"
REACT_APP_ID = "my app id"`

.env

`jobs:
  build_and_deploy:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v2
      - run: npm ci && npm run build
        env:
          REACT_APP_FIREBASE_API_KEY: '${{ secrets.REACT_APP_FIREBASE_API_KEY }}'
          REACT_APP_AUTH_DOMAIN: '${{ secrets.REACT_APP_AUTH_DOMAIN }}'
          REACT_APP_DATA_BASE_URL: '${{ secrets.REACT_APP_DATA_BASE_URL }}'
          REACT_PROJECT_ID: '${{ secrets.REACT_PROJECT_ID }}'
      - uses: FirebaseExtended/action-hosting-deploy@v0
        with:
          repoToken: '${{ secrets.GITHUB_TOKEN }}'
          firebaseServiceAccount: '${{ secrets.FIREBASE_SERVICE_ACCOUNT_PROJECT_EEEEEEE~ }}'
          channelId: live
          projectId: project-eeeeeeee~`

hosting.yml

However, after deployment, the key appears in source > main.js. Is it supposed to be like this? I can't hide it?

enter image description here

I want to know how to hide the API key.

  • It's not meant to be hidden, and you can fully hide it at all, since the data is required on the client to make the client work correctly. – Doug Stevenson Feb 08 '23 at 13:58
  • https://stackoverflow.com/questions/37482366/is-it-safe-to-expose-firebase-apikey-to-the-public Thank you for the comments. I got an alarm saying it's similar to this question. My question will be deleted soon. – usercrUdwiGhY153 Feb 08 '23 at 14:52

0 Answers0