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

Blitz.JS Deployment: TypeError: Cannot read property '$create' of undefined #239

Open
jatidevelopments opened this issue Nov 17, 2021 · 1 comment

Comments

@jatidevelopments
Copy link

jatidevelopments commented Nov 17, 2021

I have successfully deployed BlitzJS to AWS. However, when I try to login or signup an account I get an Error:
Bildschirmfoto 2021-11-17 um 14 46 15

I think this issue is related to blitz-js/legacy-framework#13

I don't wrap the config like in the issue in 2955, so I don't get why it's not working correctly. BlitzJS is supported with this module, right?

My blitz.config.ts looks like this:

import { sessionMiddleware, simpleRolesIsAuthorized } from "blitz"
//const withPWA = require("next-pwa")

const config = {
  middleware: [
    sessionMiddleware({
      cookiePrefix: "wardrobe",
      isAuthorized: simpleRolesIsAuthorized,
    }),
  ],
 // pwa: {
  //  dest: "public",
  //  swSrc: "service-worker.js",
//    sw: "service-worker.js",
//    reloadOnOnline: true,
//    cacheOnFrontEndNav: true,
    //disable: process.env.NODE_ENV === "development",
//  },
}

module.exports = config

Maybe it has something to do with the next-tf package. I found in "terraform-aws-next-js/packages/tf-next/src/utils/index.ts" that its parsing for next.config.js not blitz.config.js. Maybe because of that blitz can not wrap around next?

Has anybody an idea how I could fix it? Would really appreciate if somebody know a solution!

Note:

  • Yes, I specifically disabled the wrapping with next-pwa and it doesn't work. Even run terrafrom destroy, deleted .tf-next then build again with yarn tf-next and deployed again with terraform apply.
  • I am building on EC2 instance via Cloud9 on Amazon Linux:
    Bildschirmfoto 2021-11-17 um 14 56 32
@ofhouse
Copy link
Member

ofhouse commented Nov 17, 2021

In theory the module should work with Blitz.js.
I am currently not up-to-date with the build process Blitz uses.
My latest info on that is that Blitz can detect if it is built inside a Vercel-like environment and outputs a next.config.js instead of a blitz.config.js.

tf-next itself currently creates a wrapper config to ensure that some configuration is set for deploying for the serverless target.
We are in the process to remove this wrapper in blitz-js/blitz#89.
Work on it is almost finished, but needs some final touches.

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

No branches or pull requests

2 participants