question

Bkashani avatar image
0 Votes"
Bkashani asked ·

Getting error ( POST 500 Internal Server Error) when running Full-Stack Web application in Azure

I have developed a full-stack application with Vue 2, Node , Express and Postgres. I could deploy the application to Azure , and the system coming up, but when I try to do register user with Register page that I have created , I get " POST … 500 (Internal Server Error) ", as I have tried with Postman , there is no issue in saving user data with same post controller .

Notice that I have set BaseURL to ‘’ in Api.js ( Client ):

 import axios from ‘axios’
 import store from ‘@/store/store’
 export default () => {
    return axios.create({
       baseURL: ‘’,
       headers: {
            Authorization: Bearer ${store.state.token}
       }
    })
 }

this is Register controller in /Controller folder :

 //Registering user
 async register(req, res) {
 const hash = bcrypt.hashSync(req.body.password, 10);
      try {
          const user = await User.create(
          Object.assign(req.body, { password: hash })
       );
    const userJson = user.toJSON();
    res.send({
           user: userJson,
           token: jwtSignUser(userJson),
          });
   } catch (err) {
      res.status(500).send({
      error: There is error in registering: ${err},
  });
  }
 },

I have added the following web.config file in dist folder, but it doesn't resolve the issue , also I have added web.config in root and has same issue :

 <configuration>
   <system.webServer>
     <staticContent>
       <mimeMap fileExtension="woff" mimeType="application/font-woff" />
       <mimeMap fileExtension="woff2" mimeType="application/font-woff" /> 
     </staticContent>
     <rewrite>
          
       <rules>
                 <clear />
                 <rule name="Redirect to https" stopProcessing="true">
                     <match url=".*" />
                     <conditions>
                         <add input="{HTTPS}" pattern="off" ignoreCase="true" />
                     </conditions>
                     <action type="Redirect" url="https://{HTTP_HOST}{REQUEST_URI}" redirectType="Permanent" appendQueryString="false" />
                 </rule>
             </rules>
     </rewrite>
         
       <httpErrors>     
           <remove statusCode="404" subStatusCode="-1" />                
           <remove statusCode="500" subStatusCode="-1" />
           <error statusCode="404" path="/survey/notfound" responseMode="ExecuteURL" />                
           <error statusCode="500" path="/survey/error" responseMode="ExecuteURL" />
       </httpErrors>
       <modules runAllManagedModulesForAllRequests="true"/>
   </system.webServer>
 </configuration>

Could you please let me know how I could resolve the issue .


azure-webapps-development
· 1
10 |1000 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Hi @Bkashani,

What's the error that you're getting in the catch?

Regards,
Ryan

0 Votes 0 ·

0 Answers