Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(firebase): use correct key when importing firebase httpsOptions #1663

Merged
merged 7 commits into from Sep 1, 2023
Merged

fix(firebase): use correct key when importing firebase httpsOptions #1663

merged 7 commits into from Sep 1, 2023

Conversation

luc122c
Copy link
Contributor

@luc122c luc122c commented Aug 29, 2023

πŸ”— Linked issue

fix #1655
#1657
#1556
#1555

❓ Type of change

  • πŸ“– Documentation (updates to the documentation, readme, or JSdoc annotations)
  • 🐞 Bug fix (a non-breaking change that fixes an issue)
  • πŸ‘Œ Enhancement (improving an existing functionality like performance)
  • ✨ New feature (a non-breaking change that adds functionality)
  • 🧹 Chore (updates to the build process or auxiliary tools and libraries)
  • ⚠️ Breaking change (fix or feature that would cause existing functionality to change)

πŸ“š Description

The correct key is httpsOptions, however, httpOptions was being pulled in. I searched for httpOptions and this appeared to be the only remaining instance. I believe this is the root fix for #1655

πŸ“ Checklist

  • I have linked an issue or discussion.
  • I have updated the documentation accordingly.

@codecov
Copy link

codecov bot commented Aug 29, 2023

Codecov Report

Merging #1663 (27c47a7) into main (83e980b) will not change coverage.
The diff coverage is n/a.

@@           Coverage Diff           @@
##             main    #1663   +/-   ##
=======================================
  Coverage   77.79%   77.79%           
=======================================
  Files          76       76           
  Lines        7836     7836           
  Branches      805      805           
=======================================
  Hits         6096     6096           
  Misses       1738     1738           
  Partials        2        2           

@pi0 pi0 requested a review from posva August 29, 2023 10:17
@Hebilicious
Copy link
Member

@posva do we need both setGlobalOptions and the options being passed there ?

@luc122c
Copy link
Contributor Author

luc122c commented Aug 29, 2023

@Hebilicious I think #1657 is a workaround and would no longer be required. This if statement pulls from httpsOptions, which is the correct key, which is probably why it works. Setting the global options should not be necessary.

Copy link
Collaborator

posva commented Aug 29, 2023

I don’t think both are needed but since it was in docs I supposed the prΓ©fΓ¨res way just changed and using the global options changed

@y-takebe
Copy link
Contributor

Hi everyone!

I have confirmed that the code modified in this PR works as expected with regions, minInstances, etc. In this case,setGlobalOptions is not needed.

Alternatively, I have also confirmed that setting all options in setGlobalOptions works fine.

setGlobalOptions(
  firebaseConfig.httpsOptions
);

export const __firebaseServerFunctionName__ = onRequest(
  {
    // Must be set to public to allow all public requests by default
    invoker: "public",
  },
  toNodeListener(nitroApp.h3App)
);

There is no need to have both, so choose one or the other.

@luc122c luc122c requested a review from posva September 1, 2023 15:32
@pi0 pi0 changed the title fix: Use correct key when importing firebase httpsOptions fix(firebase): use correct key when importing firebase httpsOptions Sep 1, 2023
Copy link
Member

@pi0 pi0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks ❀️ I appreciate if you can confirm this PR using edge release channel if had a chance.

@pi0 pi0 merged commit 06e960d into unjs:main Sep 1, 2023
8 checks passed
@luc122c
Copy link
Contributor Author

luc122c commented Sep 2, 2023

@pi0 I'm on the edge release Nuxt 3.7.0 with Nitro 2.6.3-28226639.ab15724 but my output is still showing the incorrect httpOptions. I deleted node_modules, yarn.lock, .nuxt and .output and did a fresh build but my .output/server/chunks/nitro/firebase-gen-2.mjs still looks like this:

const nitroApp = createNitroApp();
const useNitroApp = () => nitroApp;

const firebaseConfig = useAppConfig().nitro.firebase;
const server = onRequest(
  {
    // Must be set to public to allow all public requests by default
    invoker: "public",
    ...firebaseConfig.httpOptions
  },
  toNodeListener(nitroApp.h3App)
);

The Nitro config for this project is:

  nitro: {
    preset: "firebase",
    firebase: {
      gen: 2,
      nodeVersion: "18",
      httpsOptions: {
        region: "us-east1",
      },
    },
  },

Any ideas on what to check?

@pi0
Copy link
Member

pi0 commented Sep 4, 2023

@luc122c Are you using resolutions field? (feel free to DM me @pi0 in discord!)

@luc122c
Copy link
Contributor Author

luc122c commented Sep 4, 2023

@pi0 , no it's in the devDependencies. I've messaged you :)

Edit: It works in resolutions, the region now gets factored in correctly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Firebase gen2 / region specification does not work and deploys to us-central1
5 participants