Devin
10/14/2021, 8:14 PMAmplify.configure({...})
Frank
Devin
10/14/2021, 10:20 PMDevin
10/14/2021, 10:20 PMChad (cysense)
10/15/2021, 3:15 AMDevin
10/15/2021, 2:52 PM<http://this.site|this.site> = new sst.NextjsSite(this, "Site", {
path: "frontend",
environment: {
// Pass the table details to our app
REGION: scope.region,
REACT_APP_REGION: scope.region,
TABLE_NAME: this.table.tableName,
USER_POOL_ID: this.auth.cognitoUserPool.userPoolId,
IDENTITY_POOL_ID: this.auth.cognitoCfnIdentityPool.ref,
APP_CLIENT_ID: this.auth.cognitoUserPoolClient.userPoolClientId,
},
});
This seems to work as I can see in my NextJs console that these values are passed along.
in the front end I have a config file to wire everything up. This roughly follows the template that was in the Notes tutorial.
const config = {
// Backend config
cognito: {
REGION: process.env.REACT_APP_REGION,
USER_POOL_ID: process.env.REACT_APP_USER_POOL_ID,
APP_CLIENT_ID: process.env.REACT_APP_USER_POOL_CLIENT_ID,
IDENTITY_POOL_ID: process.env.REACT_APP_IDENTITY_POOL_ID,
},
};
export default config;
Devin
10/15/2021, 2:53 PM_app.js
i have the following:
Amplify.configure({
Auth: {
mandatorySignIn: true,
region: config.cognito.REACT_APP_REGION,
userPoolId: config.cognito.REACT_APP_USER_POOL_CLIENT_ID,
identityPoolId: config.cognito.REACT_APP_IDENTITY_POOL_ID,
userPoolWebClientId: config.cognito.REACT_APP_USER_POOL_CLIENT_ID,
},
ssr: true,
});
function MyApp({ Component, pageProps }) {
console.log("config: ", config.cognito);
Devin
10/15/2021, 2:55 PMreact_devtools_backend.js:2526 [ERROR] 51:46.959 AuthError -
Error: Amplify has not been configured correctly.
The configuration object is missing required auth properties.
This error is typically caused by one of the following scenarios:
Which explains that I have misconfigured something. So I’ve tried a variety of different versions of conifgs at this point. But haven’t been able to figure out what I’ve misconfigured. I’ve used this documentation to try to find the issue. <https://docs.amplify.aws/lib/auth/start/q/platform/js/#configure-your-application>
Devin
10/15/2021, 2:56 PMundefined
in the UI so I think that I’m jsut doing something foolish at this point and have missed some straightforward step.Frank
Amplify.configure({
Auth: {
mandatorySignIn: true,
region: config.cognito.REACT_APP_REGION,
userPoolId: config.cognito.REACT_APP_USER_POOL_CLIENT_ID,
identityPoolId: config.cognito.REACT_APP_IDENTITY_POOL_ID,
userPoolWebClientId: config.cognito.REACT_APP_USER_POOL_CLIENT_ID,
},
ssr: true,
});
Maybe they should be
Amplify.configure({
Auth: {
mandatorySignIn: true,
region: config.cognito.REGION,
userPoolId: config.cognito.USER_POOL_ID,
identityPoolId: config.cognito.APP_CLIENT_ID,
userPoolWebClientId: config.cognito.IDENTITY_POOL_ID,
},
ssr: true,
});
Devin
10/15/2021, 3:14 PMDevin
10/15/2021, 3:18 PMreact_devtools_backend.js:2526 [ERROR] 17:28.604 AuthError -
Error: Amplify has not been configured correctly.
The configuration object is missing required auth properties.
This error is typically caused by one of the following scenarios:
1. Did you run `amplify push` after adding auth via `amplify add auth`?
The error persists with that as well.Devin
10/15/2021, 3:19 PMFrank
config.cognito.REACT_APP_REGION
doesn’t exist right? U only created config.cognito.REGION
. Looks like a typo to me?Devin
10/15/2021, 3:23 PMDevin
10/15/2021, 8:28 PMNextjsSite
and my actual next app incorrectly.Devin
10/15/2021, 8:30 PMDevin
10/15/2021, 8:39 PMJay
Frank
NEXT_PUBLIC_
Frank
NEXT_PUBLIC_REGION
instead of REACT_APP_REGION
Frank
Frank
Devin
10/16/2021, 2:56 PMNEXT_PUBLIC_
thanks Frank!