简体   繁体   English

具有DynamoDB的NodeJS API-配置中缺少区域,但已设置

[英]NodeJS API with DynamoDB - Missing region in config but it is set

I created a NodeJS API and when I start my server, I can do my HTTP requests with success to my AWS Dynamo DB. 我创建了一个NodeJS API,当我启动服务器时,我可以成功地向我的AWS Dynamo DB发出HTTP请求。 But about twenty seconds after the request's response, the server crashes and says "missing region in config" 但是在请求响应后大约二十秒钟,服务器崩溃并显示“配置中缺少区域”

My requests are successful so why does it do that ? 我的请求成功了,为什么要这么做呢?

This is my server.js : 这是我的server.js

const express = require('express');
const config = require('./config');
const cors = require('cors');
const createError = require('http-errors');
const bodyParser = require('body-parser');
const app = express();

// parse requests
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));

//Enable CORS for all HTTP methods
app.use(cors());

// Routes
require('./routes/survey.route.js')(app);
require('./routes/user.route.js')(app);

// Handle defaut request without any route or params
app.get('/', (request, response) => {
     response.send("Welcome to my API !");
});

// Listen on port 8080 for connections
app.listen(config.serverPort, (err) => {
    if (err) {
        return console.log('something bad happened', err);
    }

    console.log(`server is listening on ${config.serverPort}`);
});

// catch 404 and forward to error handler
app.use(function(req, res, next) {
    console.log(req);
    next(createError(404));
});
module.exports = app;

Each of my routes' requests include the file database.js 我的每条路线请求都包含文件database.js

Which has code : 里面有代码:

// Configuring the database
const AWS = require('aws-sdk');
const config = require('./config');

AWS.config.update({
    accessKeyId: config.aws_accessKeyId,
    secretAccessKey: config.aws_secretAccessKey,
    region: config.aws_region
});

And this is my config.js : 这是我的config.js

module.exports = {
    baseUrl: '/api',
    serverPort: 8080,
    aws_accessKeyId: 'XXXXX',
    aws_secretAccessKey: 'XXXXX',
    aws_region: "us-east-2"
};

module.exports = AWS;

I can't find why my app crashes in both local and EC2 instance... 我找不到为什么我的应用程序在本地实例和EC2实例中都崩溃的原因...

Haven't been able to fix this since few days of searches 搜索几天后一直无法解决此问题

通过从头开始创建新项目并删除dynamoose进行了修复

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 尝试使用Dynamoose在本地DynamoDB上运行Chai时,配置中缺少区域 - Missing region in config while trying to run Chai on local DynamoDB with Dynamoose Nodejs调用函数和变量范围问题; ConfigError:配置中缺少区域 - Nodejs Calling a function and variable scope issues; ConfigError: Missing region in config AWS Dynamodb 配置中缺少凭证,如果使用 AWS_CONFIG_FILE,则设置 AWS_SDK_LOAD_CONFIG=1 - AWS Dynamodb Missing credentials in config, if using AWS_CONFIG_FILE, set AWS_SDK_LOAD_CONFIG=1 CredentialsError:dynamoDB中的配置中缺少凭据 - CredentialsError: Missing credentials in config in dynamoDB 每次尝试从 NodeJS 调用 AWS lambda 函数时,我都会收到“错误 [ConfigError]: Missing region in config” - I get 'Error [ConfigError]: Missing region in config' each time I attempt AWS lambda function call from NodeJS 如何在Node.js中配置AWS dynamoDB区域? - How do I configure the AWS dynamoDB region in Nodejs? 如何使用opencv4node.js设置矩阵区域 - How to set a matrix region with opencv4nodejs Api 停止使用 nodejs 和 dynamodb 工作 - Api stop working using nodejs and dynamodb AWS Cognito-ConfigError:JavaScript SDK的配置中缺少区域 - AWS Cognito - ConfigError: Missing region in config for JavaScript SDK 尝试使用 Jest 模拟 SecretsManager 后“配置中缺少区域” - "Missing region in config" after attempting to mock SecretsManager with Jest
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM