Skip to content
This repository was archived by the owner on Mar 30, 2021. It is now read-only.
This repository was archived by the owner on Mar 30, 2021. It is now read-only.

Errors due to webpack not working with certain dependencies (firebase-admin) #6

Description

@Pupcakes

Is webpack absolutely necessary for this to run? It does't seem like any of this code would run client side (I hope, unless I am misunderstanding it). I started with the glitch examples in this project. I wanted to connect a firebase database but kept getting errors when trying to install the firebase-admin package. After a lot of research it seems like firebase-admin isn't compatible with webpack, I guess since it is supposed to be back-end only.

Here's my code. It's just the glitch example with firebase thrown at the top. It throws a million errors about "Field 'browser' doesn't contain a valid alias configuration"


const firebase = require('firebase-admin')
import proxy from '@fly/proxy'

// the Glitch App URL
const glitchHost = "fly-example.glitch.me"

/* Deployment instructions */
// fly apps create <app-name>
// fly deploy
// fly hostnames add <your-custom-hostname.com>

// create a proxy fetch function to Glitch
const glitch = proxy(`https://${glitchHost}`,
  {
    headers: {
      'host': glitchHost, // set HOST header to glitchHost
      'x-forwarded-host': false // Don't send x-forwarded-host header
    }
  })

fly.http.respondWith(function (req) {
  // redirect to https
  let resp = requireSSL(req)
  if (resp) return resp

  // proxy to glitch
  return glitch(req)
})

function requireSSL(req) {
  const url = new URL(req.url)

  if (url.protocol != "https:") {
    url.protocol = "https"
    url.port = '443'
    if (app.env === "development") {
      console.log("Skipping SSL redirect in dev mode:", url.toString())
    } else {
      return new Response("Redirecting", {
        status: 301,
        headers: { "Location": url.toString() }
      })
    }
  }
}

I tried having webpack just skip that require using
__non_webpack_require__("firebase-admin")
I then got an error saying: "[error] critical error: ReferenceError: require is not defined"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions