azure node js html

בנימין זיידנר 0 Reputation points
2024-09-29T12:39:33.1433333+00:00

I uploaded Node.js and HTML software, I defined an environment variable, it was local and I uploaded it to azure including a connection to the db.

Actually I can't get data to the browser even though I get a message that it is connected, can someone help give me some recommendations, for several days I can't find a solution.

I get such messages in the console:

Failed to load resource: the server responded with a status of 404 (Not Found)

https://wevote-b8eqa2gwbubcbwf0.canadacentral-01.azurewebsites.net/api/groups

WhatsApp Image 2024-09-29 at 15.36.24

Azure SQL Database
JavaScript API
JavaScript API
An Office service that supports add-ins to interact with objects in Office client applications.
979 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. akinbade abiola 16,320 Reputation points
    2024-09-29T13:21:40.9833333+00:00

    Hello בנימין זיידנר,

    Thanks for your question.

    Try to run your app locally again to confirm that the /api/groups route is functioning and returning the correct data.

    I will recommend you also take a look at your CORS settings, the browser may fail to load resources from your server.

    See: https://learn.microsoft.com/en-us/visualstudio/javascript/publish-nodejs-app-azure?view=vs-2019&source=recommendations

    You can mark it 'Accept Answer' and 'Upvote' if this helped you

    Regards,

    Abiola

    0 comments No comments

  2. בנימין זיידנר 0 Reputation points
    2024-09-29T14:09:35.9+00:00

    Thanks for the answer, I'll just clarify about the process again, it worked great when I run it on my computer with visual code, after I saw that everything is correct, that is, the sql is updated, returns answers, the forms are updated, I uploaded it to the azure environment, in fact I see the application but the data does not Keep me updated.

    This is the main page, but I expect to receive data, I do not receive data.

    https://wevote-b8eqa2gwbubcbwf0.canadacentral-01.azurewebsites.net/

    require('dotenv').config();

    const express = require('express');

    const sql = require('mssql');

    const cors = require('cors');

    const path = require('path');

    const helmet = require('helmet');

    const appInsights = require("applicationinsights");

    // הגדרת Application Insights באמצעות משתנה הסביבה

    appInsights.setup(process.env.APPLICATIONINSIGHTS_CONNECTION_STRING)

    .setAutoDependencyCorrelation(true)
    
    .setAutoCollectRequests(true)
    
    .setAutoCollectPerformance(true)
    
    .setAutoCollectExceptions(true)
    
    .setAutoCollectDependencies(true)
    
    .setUseDiskRetryCaching(true)
    
    .start();
    

    // אתחול Express

    const app = express();

    const port = process.env.PORT || 3000;

    // הגדרת CORS

    app.use(cors({

    origin: "*",

    methods: ["GET", "POST", "PUT", "DELETE", "OPTIONS"],

    allowedHeaders: ["Content-Type", "Authorization"]

    }));

    // הוספת Helmet לאבטחה

    app.use(helmet());

    // הגדרת קבצים סטטיים

    app.use(express.static(path.join(__dirname, 'wwwroot')));

    I would be very happy to hear from you

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.