Deploy Vue/.Net API project on Nginx Raspberry Pi API not reaching DB

44 Views Asked by At

On my Linux Server I been trying to figure this out for awhile now. Im not sure why this is happening. I can see my Vue website on Nginx. I can run my .Net API dll but the backend dll just gets BadRequest 400 errors and cannot execute the methods. It shows each API showing up on the console window when its running.

This is a project with my Vue Frontend and API Controller are in the same project.

I can ping the SQL database so thats not the issue

Browser Debugger Tools Console

{message: 'Request failed with status code 400', name: 'AxiosError', code: 'ERR_BAD_REQUEST', config: {…}, request: XMLHttpRequest, …}
u @ index-0c8f4f66.js:3
setInterval (async)
index-0c8f4f66.js:3     GET http://localhost:5025/Home/CountOrdersByDay 400 (Bad Request)
(anony

Controller Action

        [HttpGet]
        //[EnableCors("allows")]
        [EnableCors]
        [Route("CountOrdersByDay")]
        public async Task<IActionResult> CountOrdersByDay()
        {
            string sql = "SELECT t_worn " +
                 "FROM twhinh431200 " +
                 "WHERE t_iadt >= @dateNow " +
                 "AND t_iadt <=  @dateNext " +
                 "AND t_shst = 3 " +
                 "GROUP BY t_worn";

            try
            {
                var orderCount = await SQLCalls.CallQueryAsync(connection, sql);
                _logger.LogInformation($"{orderCount}");
                return Ok(orderCount);
            }
            catch (Exception ex) { Debug.WriteLine(ex.Message); }

            return BadRequest("Not Found");
        }

Vue Function

    const updateOrderCount = async () => {
        try {
            //const response = await axios.get('http://localhost:7031/api/Home/CountOrdersByDay');
            //const response = await axios.get('http://10.20.55.17:5025/Home/CountOrdersByDay');
            //const response = await axios.get('http://10.20.55.17/Home/CountOrdersByDay');
            const response = await axios.get('http://localhost:5000/Home/CountOrdersByDay');
            //const response = await axios.get('http://localhost:5025/Home/CountOrdersByDay');

            console.log(response.data);
            orderCount.value = response.data;

            var now = new Date();
            //lastUpdate.value = await getCurrentDateTime();
            lastUpdate.value = await newGetCurrentTime();

        } catch (error) {
            console.error(error);
        }
    }

launchsettings.json

     "applicationUrl": "https://localhost:5032;http://localhost:5000;http://0.0.0.0:5025;http://0.0.0.0:5000;"

I have the Firewall Turned OFF,

Nginx

server {
    listen 80;

    root /var/www/new/wwwroot;


    server_name _;
    charset utf-8;

    location /home {
        proxy_pass http://localhost:5025;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection keep-alive;
        proxy_set_header Host $host;
    }

    location / {
        root /var/www/new/wwwroot;
        try_files $uri $uri/ /index.html  =404;

    }

    access_log /var/log/nginx/newtest-access.log;
    error_log /var/log/nginx/newtest-error.log;
}
0

There are 0 best solutions below