Closed jatidevelopments closed 2 years ago
Hey @jatidevelopments, I'm not sure if we've had anyone use this module with Blitz yet.
In order for Blitz auth to work correctly, we need the .blitz.config.compiled.js
file to be available at runtime. This is generated in the project root at build time. The reason it's compiled is because we support blitz.config.ts
Probably the terraform module needs updated to read that file if it detects Blitz.
Would agree that this is not an issue with Blitz but with the Terraform module.
We currently build with the legacy experimental-serverless-trace
target and due to that we always create a wrapper next.config.js
that then requires the original config when running tf-next build
.
We are in the process of removing the wrapper, so this should be resolved soon.
Ok, then a workaround that probably would work is use patch-package
to change next.config.js
in the terraform module to .blitz.config.compiled.js
.
Ok, then a workaround that probably would work is use
patch-package
to changenext.config.js
in the terraform module to.blitz.config.compiled.js
.
Hi @flybayer thanks for the support!
I patched the tf-next package with patch-package
to .blitz.config.compiled.js
. Didn't helped.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.findEntryPoint = void 0;
const path_1 = require("path");
const fs_1 = require("fs");
// Looks for a `package.json` or `next.config.js` file in cwd and
// returns the result as a relative path to the basePath
function findEntryPoint(cwd) {
console.log("CHANGED THE PACKAGE")
for (const entrypoint of ['package.json', '.blitz.config.compiled.js']) {
if ((0, fs_1.existsSync)((0, path_1.join)(cwd, entrypoint))) {
return entrypoint;
}
}
throw new Error(`No package.json or next.config.js could be found in ${cwd}`);
}
exports.findEntryPoint = findEntryPoint;
I think I need to change next.config.js
in the terraform module. How am I able to do so? patch-package
is only for npm packages not for terrafrom.
Hi @ofhouse, could you tell me how long it will take to publish the new version? I need to get it work by next week.
I think I need to change next.config.js in the terraform module. How am I able to do so? patch-packageis only for npm packages not for terrafrom.
Quick explainer here: The "module" consists of two parts:
tf-next
The CLI creates a package from your Blitz / Next.js source that is consumable by AWS Lambda. Terraform then picks up the package and creates AWS resources from it that are then deployed.
So Terraform only deploys static files generated by the CLI, but does not modify or build any of the Blitz or Next source code. So the CLI ist responsible for producing an invalid package for Blitz here.
Not a big fan of giving ETAs on my Open Source projects since my estimates for update plans were mostly mixed up by my (paid) work in the past 😅 I'll try to take a look at it over the weekend.
I think I need to change next.config.js in the terraform module. How am I able to do so? patch-packageis only for npm packages not for terrafrom.
Quick explainer here: The "module" consists of two parts:
- The CLI
tf-next
- The deployable Terraform code
The CLI creates a package from your Blitz / Next.js source that is consumable by AWS Lambda. Terraform then picks up the package and creates AWS resources from it that are then deployed.
So Terraform only deploys static files generated by the CLI, but does not modify or build any of the Blitz or Next source code. So the CLI ist responsible for producing an invalid package for Blitz here.
Not a big fan of giving ETAs on my Open Source projects since my estimates for update plans were mostly mixed up by my (paid) work in the past 😅 I'll try to take a look at it over the weekend.
Hmm... Yeah I already thought that the CLI is responsible for building the Lambda Functions. That's why I was confused why changing the next.config.js
to the builded blitz.js config as @flybayer commented didn't helped.
Would be great if you could fix it over the weekend. I would maybe give a bug bounty reward if this helps for your motivation ;)
Other than that if you know a workaround for short. Then I would appreciate that too!
Learned today that Vercel is still forcing experimental-serverless-trace
as build target when it detects Blitz.
So using the server target as suggested and implemented by https://github.com/milliHQ/terraform-aws-next-js/pull/89 would not help in this case.
I would follow Vercel's evaluation that server target and serverless environment is currently not working for Blitz.
Have you tried to deploy it on Vercel if the error is also present there?
What is the problem?
I have successfully deployed BlitzJS to AWS. However, when I try to login or signup an account I get an Error: Blitz.JS Deployment: TypeError: Cannot read property '$create' of undefined
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?
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!
Paste all your error logs here:
Paste all relevant code snippets here:
What are detailed steps to reproduce this?
yarn tf-next
terraform apply
Run
blitz -v
and paste the output here:Please include below any other applicable logs and screenshots that show your problem:
terrafrom destroy
, deleted .tf-next then build again withyarn tf-next
and deployed again withterraform apply
.