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
Parameter and Secrets not working / strange behavior (next.js 13 app) #2840
Comments
Also happens during build: thomas@thomas-dev-box:~/projects/tmp/ai$ npx sst deploy --stage dev ➜ App: ai Using v1.1.0 ┌─────────────────────────────────┐ yarn run v1.22.19 Error occurred prerendering page "/". Read more: https://nextjs.org/docs/messages/prerender-error
Trace: Error: There was a problem building the "ai-stack-local" StaticSite. Need help with this error? Join the SST community on Discord https://sst.dev/discord |
Getting the same error. Nextjs app works locally, but needs the secret to run in prod. Set the secret using cli, and added to the config/app like so: // sst.config.ts
import { SSTConfig } from "sst";
import { Config, NextjsSite } from "sst/constructs";
export default {
config(_input) {
return {
name: "testapp1",
region: "us-east-1",
};
},
stacks(app) {
app.stack(function Site({ stack }) {
const NEXTAUTH_SECRET = new Config.Secret(stack, "NEXTAUTH_SECRET");
const site = new NextjsSite(stack, "site", {
bind: [NEXTAUTH_SECRET],
});
stack.addOutputs({
SiteUrl: site.url,
});
});
},
} satisfies SSTConfig; // next.config.js
/** @type {import('next').NextConfig} */
const nextConfig = {
experimental: {
appDir: true,
},
webpack: (config) => {
config.experiments = config.experiments || {}
config.experiments.topLevelAwait = true
return config
},
}
module.exports = nextConfig // [...nextauth].ts
import NextAuth from "next-auth/next"
import EmailProvider from "next-auth/providers/email"
import { PrismaAdapter } from "@next-auth/prisma-adapter"
import { PrismaClient } from "@prisma/client"
import { Config } from "sst/node/config"
const prisma = new PrismaClient()
// https://next-auth.js.org/configuration/initialization#route-handlers-app
export const authOptions: any = {
adapter: PrismaAdapter(prisma),
// debug: true,
session: {
strategy: "jwt",
},
providers: [
EmailProvider({
server: process.env.EMAIL_SERVER,
from: process.env.EMAIL_FROM,
}),
],
secret: Config.NEXTAUTH_SECRET,
}
export default NextAuth(authOptions) |
Hmm those kinda look right to me. Can you post this in #help and tag |
+1 also seeing this issue during a next build |
Is there a Discord thread for this? We don't use GitHub issues for support. |
sorry we don't use discord in our company, anyway i'm not looking for support. The example from the docs is not working and secrets and parameters seem not to work with next.js app. So this is a bug report... Project to verfiy: Steps: |
@thomas-schmidt-fellowork can you please try downgrading sst to v2.7.2 and see if works? If it does, then we could track the culprit down to this change: https://github.com/serverless-stack/sst/pull/2824/files#diff-3d9bee2d0f437d7e723c091ef7c33c1b1ede613b8924f6d3d86c34ef8e06e8faR32-R45 |
we started with version 2.5.2 |
It also seems that new client components of next js 13 seem not to work. If i remove either "use client" or the Client import of sst it works again.
Import trace for requested module:
|
I see this being talked about on Discord and unfortunately we don't use GitHub issues to track these. |
There r a couple issues here. Lemme reply to each one. Issue 1: build time error: Cannot find
|
I'm seeing errors with this also. I followed Next + SST setup tutorial, and then the Parameters/Secrets tutorial.
Create a new app:
I made a repo here that reproduces: https://github.com/sennett/sst-env-vars-cannot-use
Cheers. EDIT: I tried this all the way back to v2.11.14 and it gave the same error every time. Does anyone have any ideas? |
Replied on discord. |
since nothing happend for almost three months, we moved away from sst. |
I posted the issue I was having with It's also confusing that you expressed displeasure about it taking place on Discord right after you said "Is there a Discord thread for this? We don't use GitHub issues for support.". I'm not trying to be unkind, but that sounds a little erratic.
There isn't a link to a Discord thread on this topic anyplace that I can locate. @jayair , could you give the URL of it, please? This relationship between Github and Discord was already puzzling enough before your last comment 😅 |
Yeah so what happens is that people post in both locations sometimes. I comb through the GH issues telling people to post their help questions on Discord after I go through and answer everything on there. So in this case, I had already replied on there. On the broader issue, unfortunately most people don't read the pinned message. We are actually considering closing our GH issues because of this. |
I followed the steps in the official guide on how to get it running. The main issue here is that the guide was not up to date, or something was broken in this package at that time. I built one very quick personal demo project with SST and got 'something' to run. The insistence on not posting issues on github is a dirty tactic that hides the endless stream of problems with this product. The same error messages are asked about on Discord and it's always due to the confusion around SST. This is a "wait 2 years, then check in again" kinda product. @fwang My export { default } from "next-auth/middleware"
export const config = { matcher: ["/secure/:page*"] } |
Just can +1 my fellow commenters. I am not very active on Discord, since it is very noisy. —— This being said, the issues raised here where (initially) a bug report, which then ended in a “support request” - so nothing bad on closing the issue. However, I think we as an OSS community should follow principles of the things we are relying on (in this case Next.js - speaking of OpenNext). I think it should be possible to have constants that are available on both client- and server-side, since Next.ja also allows us to. I would understand, when the infrastructure is not able to get this properly, but I am still standing the point, that we could try to adjust anything to get this working. ——- Some personal note: I moved away from migrating my Vercel setup to SST/AWS, since this issue is blocking the migration heavily. Having a really big-scale product and needing to migrate multiple places to use other setup’s than the “Config” is simply too much for a migration. |
I understand the frustration but this is not what we are trying to do:
We are a small team and we can't maintain two different places for support or issues. Our community is more active on Discord and it makes sense for us to primarily spend our time there. Though this might change in the future. |
It's easier track issue on github. Search is better too. The long post format allows ppl to add new info later, on discord it's now or never. Getting things done on discord does not mean the same thing wouldn't be 10x easier on github. |
Hi everyone,
i created a next.js app following this tutorial: https://sst.dev/examples/how-to-create-a-nextjs-app-with-serverless.html.
So we use the "drop in" approach for sst. We use the newest version of sst and next. Cleaned out any Stack and Bootstrap stuff in AWS.
In our Stack we added some Parameters and Secrets like so:
`const nextAuthSecret = new Config.Secret(stack, "NEXTAUTH_SECRET");
.......
We then populated the secret values with cli for local dev and prod environment.
When we deploy the app and open the landing page of the app we always hit the same error: Some required environment variables are not set:
"This is usually the case when you are using an older version of SST. Please update SST to the latest version to use the SST Config feature."
I thought they are being populated automatically? This also happens with any secret and parameter, so not related to next-auth.... and we use the newest version of sst
best
Thomas
The text was updated successfully, but these errors were encountered: