amplify-js: Auth Error: Amplify has not been configured correctly using Nuxt.js
Describe the bug The developer console is stating the below error, however this is NOT impacting any functionality. I am able to Sign In, Sign Up, Confirm Code, Fetch Current Authed User with no errors or issues.
[ERROR] 06:02.945 AuthError -
Error: Amplify has not been configured correctly.
This error is typically caused by one of the following scenarios:
1. Make sure you're passing the awsconfig object to Amplify.configure() in your app's entry point
See https://aws-amplify.github.io/docs/js/authentication#configure-your-app for more information
2. There might be multiple conflicting versions of aws-amplify or amplify packages in your node_modules.
Try deleting your node_modules folder and reinstalling the dependencies with `yarn install`
Here is the output when enabling LOG_LEVEL = ‘DEBUG’:
[DEBUG] 06:04.890 AuthClass - getting current authenticated user
ConsoleLogger.js?36de:84 [DEBUG] 06:04.916 AuthClass - getting current authenticated user
ConsoleLogger.js?36de:84 [DEBUG] 06:04.917 AuthClass - getting current authenticated user
ConsoleLogger.js?36de:84 [DEBUG] 06:04.927 AuthClass - cannot load federated user from auth storage
ConsoleLogger.js?36de:84 [DEBUG] 06:04.927 AuthClass - get current authenticated userpool user
ConsoleLogger.js?36de:84 [DEBUG] 06:04.930 AuthClass - cannot load federated user from auth storage
ConsoleLogger.js?36de:84 [DEBUG] 06:04.931 AuthClass - get current authenticated userpool user
ConsoleLogger.js?36de:84 [DEBUG] 06:04.931 AuthClass - cannot load federated user from auth storage
ConsoleLogger.js?36de:84 [DEBUG] 06:04.931 AuthClass - get current authenticated userpool user
ConsoleLogger.js?36de:84 [DEBUG] 06:04.969 AuthClass - getting current authenticated user
ConsoleLogger.js?36de:84 [DEBUG] 06:04.998 AuthClass - cannot load federated user from auth storage
ConsoleLogger.js?36de:84 [DEBUG] 06:05.1 AuthClass - get current authenticated userpool user
To Reproduce Steps to reproduce the behavior:
- Create Nuxt.js project
- Install and Manually Configure Amplify
- Error occurs on every page reload
Expected behavior I am hoping to not have an error message in the console if there are no actual errors with the functionality.
Environment
System:
OS: Linux 5.0 Ubuntu 18.04.2 LTS (Bionic Beaver)
CPU: (4) x64 Intel(R) Core(TM) i5-6402P CPU @ 2.80GHz
Memory: 1.45 GB / 15.63 GB
Container: Yes
Shell: 4.4.20 - /bin/bash
Binaries:
Node: 10.16.0 - ~/.nvm/versions/node/v10.16.0/bin/node
npm: 6.9.0 - ~/.nvm/versions/node/v10.16.0/bin/npm
Browsers:
Chrome: 77.0.3865.90
Firefox: 70.0
npmPackages:
@nuxtjs/axios: ^5.3.6 => 5.8.0
@nuxtjs/vuetify: ^1.0.0 => 1.9.0
aws-amplify: ^1.2.4 => 1.2.4
aws-amplify-vue: ^0.3.3 => 0.3.3
nuxt: ^2.0.0 => 2.10.2
vue-google-autocomplete: ^1.1.0 => 1.1.0
npmGlobalPackages:
@aws-amplify/cli: 1.8.5
@vue/cli: 3.9.3
npm: 6.9.0
serverless: 1.50.1
Sample code Here is my amplify config, obviously removed the actual values and replaced with x’s.
import Amplify, { Auth } from 'aws-amplify';
Amplify.configure({
Auth: {
identityPoolId: 'xxxxxxxxxxxxxxxxxxxxxxxx',
region: 'us-east-2',
userPoolId: 'xxxxxxxxxxxxxxxxxxxxxxxxxx',
userPoolWebClientId: 'xxxxxxxxxxxxxxxxxxx'
}
});
Amplify.Logger.LOG_LEVEL = 'DEBUG';
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 21
- Comments: 84 (7 by maintainers)
Links to this issue
Commits related to this issue
- Amplify update Potential suggestion from https://github.com/aws-amplify/amplify-js/issues/4315 — committed to ComTacTraining/ctt by moseley 3 years ago
- feat: migrate to latest Amplify JS and Quasar UI 1.x #143 (#144) * chore: cleanup old structure * chore: initial skeleton w/ all breaking changes fixed * chore: sync package.json Signed-off... — committed to aws-samples/aws-serverless-airline-booking by heitorlessa 3 years ago
- https://github.com/aws-amplify/amplify-js/issues/4315 Can't resolve this issue — committed to bobbyhadz/aws-amplify-react-auth by bobbyhadz 3 years ago
- Revert "https://github.com/aws-amplify/amplify-js/issues/4315" This reverts commit 6577a267c055d56b7dfb52cf58ed177e4a68a2be, reversing changes made to 2d31778abc75ee834e698f24b5e36ee5faebdf13. — committed to bobbyhadz/aws-amplify-react-auth by bobbyhadz 3 years ago
I 'm having the same issue in
"aws-amplify": "^3.0.11"I found out
Authmodule didn’t load configs ofaws-exports, so my solution for this issue is:Auth module can load awsconfig directly by
Auth.configure(awsconfig)I don’t understand why
Authmodule didn’t loadaws-exportfromAmplify.configure, but I resolve this issue by this solution for now.Still having the same issue. Any help ? Thanks
Still getting this issue with version
3.4.29in anext.jsproject. If someone finds a working version please let me know.My configuration looks like:
In development everything works fine, once I deploy to production I get this error:
The code quality on AWS Amplify (or lack thereof) blows me away. How AWS sells this is beyond me.
Amplify’s whole purpose is to ease integration of a suite of services and improve productivity. When our teams fight the framework’s quality on basics like this, it not only erases any efficiency, speed, and cost benefit for us, it hampers our ability to execute and costs us more.
If we had back in developer time what we have spent in wasted time fighting the framework’s atrocious quality and reliability it’d be more than our entire AWS bill.
Nothing is perfect nor should it be or can it be, but this was the worst architectural decision I’ve made in a long time to have our teams on this. The promise was there, the idea is great, but the execution is of the utmost worst quality with a fragmented universe of packages, deps, and inconsistencies that are bad enough without all the random bugs, but are even worse when they don’t work well together because the UI frameworks don’t jive with the core, etc, etc.
How in the world do builds that are so badly broken in relatively common environments make it to release so often and consistently with Amplify? I don’t mean to sound harsh, but we all know the world’s supposed cloud leader and largest provider in the world can easily do better, and Amplify isn’t a particularly bleeding edge product, but it is pretty important for developer productivity & customer productivity, and any quality issue in it cascades into applications built upon and with it. And these elementary issues have been going on for years now, why can’t AWS get control of the quality here on releases?
In what world is this acceptable?
And it’s been this way for years, and it doesn’t have to be this bad! It’s not like it’s a new area of medicine we’re needing to make discoveries in for decades to come and we’re gonna crawl before we walk, this is a collection/glue offering of other production-grade services in highly established languages with very well-defined interfaces in an ecosystem AWS completely controls on its own, 100%, and we can’t even keep the most basic level of functionality from suffering regressions, let alone stopping new bugs that always crop up!
@swaminator - can you give us and/or our support rep some resources to address this, but more importantly, discuss and share what the quality plan here is. We all know Amplify doesn’t need to be this bad, why is it? And what are you doing to change that? When will this happen? I have to say (esp also being a Google Cloud, Firebase, and Azure Mobile Apps [etc] customer), Amplify ranks as the biggest mistake I’ve made as a technology executive in choosing a platform. Any possible value add from the product vision (which is GREAT) is completely destroyed and orders of magnitude dumped into the negative with the myriad of issues. If we didn’t already have so much invested in it we would be GONE, but we are quickly reaching the point where it is becoming such an impediment to productivity, it will actually make more sense in schedule and finance to bite the bullet and migrate a different framework that actually makes good on its developer productivity and management productivity story rather than adding a whole other layer of madness, expense, delay, unpredictability, and risk.
And don’t miss the party over at #7555, either!
I tried above solution:
The same issue still happens, error:
version:
“aws-amplify”: “^3.0.11”
this is soooo shit… amplify never registers auth. it will register everything that i dont need except auth. Because when auth initialises it’s using a different instance of amplify ! brilliant.
So, even though i am passing auth config, because its not a registered component. it never gets configured.
This issue should be reopened
I first ran into it nearly two years ago and the amplify team seems unable to answer or help the issue so far.
We really need this resolved, please and thank you
Why is this ticket closed after this comment?
Ctrl + F & Searching ‘.configure()’ shows you a bit about it being a function but not much about:
https://aws-amplify.github.io/amplify-js/api/#configuration
solved my problem, in Aug 2020 👍
Importing Auth from
aws-amplifyworked, but I had to import the Amplify object itself from@aws-amplify/corelike:Otherwise, I was getting the same issue as everyone else. So +1 for the above stated solution.
Well, I am using ionic (angular) with amplify and this bugged me too. Therefore, I had to update my main.ts file with the following,
The above code does what the error asks for. Unfortunately there are a lot of issues with the Amplify Framework and I don’t think this is production ready at all.
Same issue here, aws-amplify 2.2.6
Updating to
"aws-amplify": "^2.2.0"solved the issue for me.Having this issue with 3.3.14, amazing stuff! Loving the consistency
It seems more so related to changing versions, not a specific version tbh, but not sure on the root cause
Edit:
I ended up adding the below as per above, in addition to having Amplify.configure already setup:
import { Auth } from ‘@aws-amplify/auth’ Auth.configure(awsconfig)
I also had to do the same with other modules, eg. with Api: import { API } from “aws-amplify”; API.configure(aws_exports);
Why is this all of a sudden required? Why is doing Amplify configure insufficient?
Resolving as above statement that the resolution is to upgrade to `"aws-amplify: “^2.2.0”
I’m having this issue… aws-amplify v2.2.6
Worked.
After a year this solution still saved my ass. Thanks.
Just a reminder, if you didn’t manage to set the
.envproperly, there would be the same error in your console.So maybe we could try to write some fixed string value to replace the
awsconfigand have a try first.Often mistake for
.env:REACT_APP_and vue needVUE_APP_..env."or'for the string env value.Hope it helps.
This issue should not be closed until proper documentation of Auth.configure(config); is available. Please see: https://aws-amplify.github.io/amplify-js/api/#configuration
I just resolved this in my project by calling
Auth.configure()within ALL files thatAuthis used.Reason is during aws-amplify minor version upgrade it changed required @aws-amplify/auth version. But also @aws-amplify/ui-component requires @aws-amplify/auth. So if you allow range versions of aws-amplify (for example ^), you can have updated aws-amplify package (newer minor versions), which required different @aws-amplify/auth package than @aws-amplify/ui-components package. As a result in ui you have two different @aws-amplify/auth packages imported - one from configuring aws-amplify, and second from using @aws-amplify/ui-components (this library is used by for example @aws-amplify/ui-react, etc). So ui components have their own auth module, which doesn’t know anything about being configured - that’s where error comes from. In my case solution was to reinstall all amplify libraries to newest versions (note that @aws-amplify/ui-* libraries changed from 0.* versions to 1.* versions), so that they don’t import @aws-amplify/auth module twice.
@cybercussion that worked for me too, thanks for sharing. Why do we have to spend so much time with this? Why didn’t I choose firebase???
Using Nuxt in SPA mode generally defeats the purpose of using Nuxt for 99% of people.
This is still an issue for me using
aws-amplify: ^4.3.1So is it safe to say
@aws-amplifyworks butaws-amplifyhas issues? I think I’ve had this in use now for 7 months and just started having issues. I don’t know the difference between node_modules but I was seeing a lot of extra files get created on builds. I guess I need to look if its a legacy vs new thing or a case where its a ‘owned’ package and prior it wasn’t? Should we even be installing the aws-amplify vs @aws-amplify?I previously had:
https://stackoverflow.com/questions/63838978/moving-aws-exports-js-to-another-angular-project/63848309#63848309
I was looking for this same issue, but in React.js, not Nuxt.js. The following has resolved this issue on my end, given that you use hook-based functional components in React with
"aws-amplify": "^3.0.10"and"@aws-amplify/ui-react": "^0.2.9".TL;DR: Load
Amplify.configurewhere your app initializes.Still didn’t fix the error display for me (the actual authentication process works). I’m including only the
aws-exportsfile following the instructions onMultiple frontends.Same
"aws-amplify": "^3.0.11".Same happens using the slightly different
re-use-existing-authentication-resourceapproach.I have not solved this issue, however I’m using nuxt in Generate mode when deployed so I’m not actually worrying about it.
The error is being thrown by Nuxt SSR, so if you’re not using SSR then it shouldn’t actually be a problem when deployed.
Even in SSR mode you can accomplish everything client side, you can then store the JWT token as a cookie so that you have access to it server side.
The annoying part is constantly seeing the error in dev tools anytime you refresh (only in SSR mode, error goes away in Generated or SPA mode).
Just ran into this with aws-amplify 3.3.14 and @aws-amplify/ui-react 0.2.34. Updated a functioning app from 3.3.13 and 0.2.33 and suddenly this error is popping up on the withAuthenticator login page.
@Johnniexson Check #5671 , when you don’t import
aws-amplify.Auth, you may also get this error. Solution is to import it anywhere inside the projectI also have this same problem!
In my case, the error came from using
Auth.currentAuthenticatedUserwhen trying to determine if a federated user is logged in or not.If amplify can’t find a federated user, it falls back to trying to find a userpool user, and eventually fails here.
I think this should probably be changed from:
to:
So it doesn’t short circuit if
userPoolIdisn’t provided.The error is annoying but ultimately doesn’t impact my the functionality 🤷♂️
Thanks padzikm, that worked for me! I ran:
yarn add @aws-amplify/ui-react@latestand bingo back in. Half a day wasted, ho humSame here, after running:
rm -rf package-lock.json node_modules npm add aws-amplify@latestAnd adding this to all files importing @aws-amplify/core or @aws-amplify/auth, it started working again.
Auth.configure(AwsConfig);I also come across this error today:
but for no obvious reason. I had been working on a feature branch, the only thing added was a cron job lambda. No frontend stuff at all. Then I merged the feature branch to develop and after that I got this error.
It continued to work locally where I am running amplify 4.41.2 but failed on the hosted version of the same branch.
After adding:
It started to work on the hosted version as well but these lines were not there before and it was just fine.
@wlee221 this worked for me thanks :
Our issues here were related that some change in 3.4.7 -> 3.4.17 brought up an issue related to duplication with the aws-amplify library that existed from before modularization was used: removing the modularized auth library resolved the issue. Thank you @elorzafe
@24601, Can you look to reopen a new issue with your above callout, I want to be able to track this as a new issue. Thanks ahead of time!
3.3.11was working ok but upgrading to3.3.13seemed to introduce the issue again.Resolved my issue also that cropped up out of nowhere after an update to
aws-amplify@3.2.0. Thanks!Well, afaik amplify works in client mode only, so I’m not sure how it will behave in your case. However, it got me thinking and I’ve changed my authentication plugin to run in client mode as well (not sure why I set otherwise to begin with), which resolved the issue completely. To sum it up, I currently have both amplify.js and my custom auth plugin registered in nuxt.config.js in client mode and the error is finally gone.
Having exactly the same issue with Nuxt in Universal mode and latest amplify version: 4.25.0 Everything seems to work fine, but the error still appears. I’ve tried all solutions/workarounds proposed here to no avail. Any ideas please?
yarn remove aws-amplifyand after
yarn add aws-amplify@latesthelped me