Vercel 500 internal error! Cannot get logged in - javascript

[GET] /auth/signin?callbackUrl=http://localhost:3000
17:22:23:77
2021-10-24T12:22:24.062Z a07d6ace-3b47-4472-a45b-f7ef9989a9b5 ERROR [next-auth][error][CLIENT_FETCH_ERROR]
https://next-auth.js.org/errors#client_fetch_error request to http://localhost:3000/api/auth/providers failed, reason: connect ECONNREFUSED 127.0.0.1:3000 {
error: {
message: 'request to http://localhost:3000/api/auth/providers failed, reason: connect ECONNREFUSED 127.0.0.1:3000',
stack: 'FetchError: request to http://localhost:3000/api/auth/providers failed, reason: connect ECONNREFUSED 127.0.0.1:3000\n' +
' at ClientRequest.<anonymous> (/var/task/node_modules/node-fetch/lib/index.js:1461:11)\n' +
' at ClientRequest.emit (events.js:400:28)\n' +
' at Socket.socketErrorListener (_http_client.js:475:9)\n' +
' at Socket.emit (events.js:400:28)\n' +
' at emitErrorNT (internal/streams/destroy.js:106:8)\n' +
' at emitErrorCloseNT (internal/streams/destroy.js:74:3)\n' +
' at processTicksAndRejections (internal/process/task_queues.js:82:21)',
name: 'FetchError'
},
path: 'providers',
message: 'request to http://localhost:3000/api/auth/providers failed, reason: connect ECONNREFUSED 127.0.0.1:3000'
}
2021-10-24T12:22:24.099Z a07d6ace-3b47-4472-a45b-f7ef9989a9b5 ERROR TypeError: Cannot convert undefined or null to object
at Function.values (<anonymous>)
at SignIn (/var/task/.next/server/pages/auth/signin.js:75:26)
at d (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:33:498)
at bb (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:36:16)
at a.b.render (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:42:43)
at a.b.read (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:41:83)
at Object.exports.renderToString (/var/task/node_modules/react-dom/cjs/react-dom-server.node.production.min.js:52:138)
at Object.renderPage (/var/task/node_modules/next/dist/server/render.js:596:45)
at Function.getInitialProps (/var/task/.next/server/pages/_document.js:601:19)
at Object.loadGetInitialProps (/var/task/node_modules/next/dist/shared/lib/utils.js:69:29) {
page: '/auth/signin'
}
RequestId: a07d6ace-3b47-4472-a45b-f7ef9989a9b5 Error: Runtime exited with error: exit status 1
Runtime.ExitError
I am using vercel for hosting and after a week of coding and finally uploading the build when I try to login it gives me this error I don't understand this and would really appreciate if any of you could help me this is the URL https://insta-2-0-ebon.vercel.app/ of the app

If you are using .env(process.env) file check your variable must have prefix NEXT_PUBLIC_ if not check your URL back-end you are currently using localhost

I had the same issue, and it is not only about the NEXTAUTH_URL to be added if you are using an adapter, for me it was MongoDB don't forget to add MONGODB_URI variable, but I also spent a lot of time and the error message was misleading but finally after adding the connection URI of mongo it works

If you using next.js, try adding NEXT_PUBLIC_VERCEL_URL.
https://vercel.com/docs/concepts/projects/environment-variables#

Related

oAuth1 Failing To Provide Signature for Strings With Square Brackets - Error 401

I am obtaining an error when trying to use my oAuth1 signature generator for square bracket endpoints.
products/{sku}- Success
products?searchCriteria[filterGroups][0][filters][0][field]=sku&searchCriteria[filterGroups][0][filters][0][condition_type]=eq&searchCriteria[filterGroups][0][filters][0][value]={sku} - ERROR
Error Message:
AxiosError: Request failed with status code 401
at settle (/var/task/node_modules/axios/dist/node/axios.cjs:1261:12)
at IncomingMessage.handleStreamEnd (/var/task/node_modules/axios/dist/node/axios.cjs:2444:11)
at IncomingMessage.emit (node:events:539:35)
at endReadableNT (node:internal/streams/readable:1345:12)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
code: 'ERR_BAD_REQUEST',
At the bottom of the cloudwatch log: data: { message: 'The signature is invalid. Verify and try again.' }
How do I encode square brackets to create the correct signature?

How to make AWS S3 request retryable?

Sometimes when I download multiple files from S3 bucket using node sdk, the request will timeout for one of the downloads. I would like for the request to just retry to attempt to download again.
The json error response says retryable: false.
Is there a way I can configure it to be true?
Here is the error:
{ TimeoutError: Connection timed out after 480000ms
at ClientRequest.<anonymous> (node_modules/aws-sdk/lib/http/node.js:83:34)
at Object.onceWrapper (events.js:272:13)
at ClientRequest.emit (events.js:180:13)
at ClientRequest.emit (domain.js:421:20)
at TLSSocket.emitTimeout (_http_client.js:703:34)
at Object.onceWrapper (events.js:272:13)
at TLSSocket.emit (events.js:180:13)
at TLSSocket.emit (domain.js:421:20)
at TLSSocket.Socket._onTimeout (net.js:396:8)
at ontimeout (timers.js:466:11)
at tryOnTimeout (timers.js:304:5)
at Timer.listOnTimeout (timers.js:267:5)
message: 'Connection timed out after 480000ms',
code: 'TimeoutError',
time: 2019-04-01T17:58:41.010Z,
region: 'us-west-2',
hostname: 'bucket-name',
retryable: false,
statusCode: 200,
retryDelay: 129.76727762396757 }
I am not sure of how you are using the resources as you didn't share your code, but this might help you.
// setting retries
var s3 = new AWS.S3({apiVersion: '2006-03-01', maxRetries:10});
S3 sdk documentation - maxRetries

Catch error on IBM Watson IoT NodeJS client

I'm using the IBM Watson IoT NodeJS client to connect and use IBM Watson IoT.
This works when my object with credentials etc. is correct:
var client = new ibm_watson_iot.IotfGateway(MY-JSON-OBJECT-WITH-CREDENTIALS);
But if credentials is wrong, then I get:
events.js:160
throw er; // Unhandled 'error' event
^
Error: getaddrinfo ENOTFOUND 1234xyz.messaging.internetofthings.ibmcloud.com 1234xyz.messaging.internetofthings.ibmcloud.com:8883
at errnoException (dns.js:28:10)
at GetAddrInfoReqWrap.onlookup [as oncomplete] (dns.js:76:26)
error: Forever detected script exited with code: 1
How do I correctly catch this error in a nice way?
You can always use try/catch block to handler error like that
try{
var client = new ibm_watson_iot.IotfGateway(MY-JSON-OBJECT-WITH-CREDENTIALS);
}
catch(error) {
console.log("Error in connection.. Probably configuration object")
}

ADAL node js username password authentication

I am using the adal node js library 1.22, and trying to authenticate a user with username and password. I am getting a "unable to get local issuer certificate" error. The user is federated and the error happens on realm discovery.
var context = new AuthenticationContext(authorityUrl);
context.acquireTokenWithUsernamePassword(resource, sampleParameters.username, sampleParameters.password, sampleParameters.clientId, function(err, tokenResponse) {
if (err) {
console.log('well that didn\'t work: ' + err.stack);
} else {
console.log(tokenResponse);
}
});
The error stack:
Stack:
Error: unable to get local issuer certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
{ Error: unable to get local issuer certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38) code: 'UNABLE_TO_GET_ISSUER_CERT_LOCALLY' }
Wed, 14 Jun 2017 08:44:17 GMT:079c7b70-6ae1-461c-b433-cc3fe0c22783 - TokenRequest: VERBOSE: getTokenFunc returned with err
well that didn't work: Error: unable to get local issuer certificate
at Error (native)
at TLSSocket.<anonymous> (_tls_wrap.js:1092:38)
at emitNone (events.js:86:13)
at TLSSocket.emit (events.js:185:7)
at TLSSocket._finishInit (_tls_wrap.js:610:8)
at TLSWrap.ssl.onhandshakedone (_tls_wrap.js:440:38)
Can you please advise on what certificate i am missing and where to find it.
EDIT
after digging through the code i found that commenting out the global agent.ca part of the code resolved this issue and the library was able to perform a few steps after that, but it had a problem returning the token response from ADFS.
The log:
Wed, 14 Jun 2017 10:39:39 GMT:425e3117-a495-4f8e-8a12-e7e64dd0e37b - OAuth2Client: INFO: Get TokenServer returned this correlationId: 425e3117-a495-4f8e-8a12-e7e64dd0e37b
Wed, 14 Jun 2017 10:39:39 GMT:425e3117-a495-4f8e-8a12-e7e64dd0e37b - OAuth2Client: ERROR: Get Token request returned http error: 401 and server response: {"error":"invalid_client","error_description":"AADSTS70002: The request body must contain the following parameter: 'client_secret or client_assertion'.\r\nTrace ID: aadf1560-18ec-46f9-83b6-5932c2131200\r\nCorrelation ID: 425e3117-a495-4f8e-8a12-e7e64dd0e37b\r\nTimestamp: 2017-06-14 10:39:41Z","error_codes":[70002],"timestamp":"2017-06-14 10:39:41Z","trace_id":"aadf1560-18ec-46f9-83b6-5932c2131200","correlation_id":"425e3117-a495-4f8e-8a12-e7e64dd0e37b"}
Is there any configuration that i forgot,
if (!parametersFile) {
sampleParameters = {
tenant : 'tenant.onmicrosoft.com',
authorityHostUrl : 'https://login.microsoftonline.com',
clientId : 'aa461028-1fgf-46e5-ab9b-5adca324febc',
username : 'user#domain.net',
password : 'lamepassword'
};
}
var authorityUrl = sampleParameters.authorityHostUrl + '/' + sampleParameters.tenant;
var resource = '00000002-0000-0000-c000-000000000000';
The resource owner flow is strongly discouraged, and in some cases like federated users or users that require MFA, will just not work. This flow is the one in which your application handles the user's username and password directly and sends those in the request to the identity provider. This approach won't work if there are any extra interactions required as part of authentication such as requiring a second factor or dealing with federation. For these reasons and simple security principles (removing the need for the application to deal with the username and password) it's better to avoid this flow.
Since you are dealing with federated users, the resource owner won't work for you leaving you with the two preferred alternatives:
Use the authorization code flow if you want to authenticate as a user
Use the client credentials flow if you want to authenticate as an application.
See the "Web Application to Web API" scenario in the "Azure AD Authentication Scenarios" documentation for more information about choosing between these two options.

TypeError: res.writeHead is not a function chapter 6 Fullstack javascript development with MEAN

So I'm following along with the Full Stack Javascript development offered by Sitepoint and I've ran into a problem found within chapter 6. I've set up a basic http server which should allow incoming connections.
When I run index.js, I get a log to the console saying it is successfully running at my designated address(127.0.0.1:1337)
As soon as I try to go to that address in my browser it fails to connect and I get this error in my terminal
TypeError: Cannot read property 'toUpperCase' of undefined
at Server.<anonymous> (/Users/user/Documents/Git projects/human-resources/index.js:8:26)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
It obviously has a problem with this line
req.method = req.method.toUpperCase();
But I don't know why, I thought maybe if I comment it out it'll work, but when I do that I get a similar error to the above but this time says res.writeHead is not a function
TypeError: res.writeHead is not a function
at Server.<anonymous> (/Users/user/Documents/Git projects/human-resources/index.js:12:9)
at emitTwo (events.js:106:13)
at Server.emit (events.js:191:7)
at HTTPParser.parserOnIncoming [as onIncoming] (_http_server.js:543:12)
at HTTPParser.parserOnHeadersComplete (_http_common.js:105:23)
If anyone could offer some insight into where I or my code is going wrong that would be great my full code is listed below..
var http = require('http');
http.createServer(function (res,req) {
//A parsed url to work with in case there are parameters
var _url;
//In case the client uses lower case for methods
req.method = req.method.toUpperCase();
console.log(req.method + ' ' + req.url);
if (req.method !== 'GET') {
res.writeHead(501, {
'Content-Type': 'text/plain'
});
return res.end(req.method + ' is not implemented by this server');
}
if (_url = /^\/employees$/i.exec(req.url)) {
//return a list of employees
res.writeHead(200);
return res.end('employee list');
} else if (_url = /^\/employees\/(\d+)$/i.exec(req.url)) {
//find employee by id in the route
res.writeHead(200);
return res.end('a single employee');
} else {
//try to send the static file
res.writeHead(200);
return res.end('static file maybe');
}
}).listen(1337, '127.0.0.1');
console.log('Sever Running at http://127.0.0.1:1337/');
I have used the request and response in the http.createServer() in the wrong order, I used response then request, should be request and then response like so;
http.createServer(function (req,res) {

Categories