Anurag Mishra
Anurag Mishra

Reputation: 699

I have deployed the build folder inside wwwroot folder using ftp. But still my web url is running it's default page

I have deployed the create-react-app build folder inside site/wwwroot/ folder using ftp in Azure. But still my web url is running azure's default page

I have created the build using npm run build command

So how can I deplot my static create-react-app on Azure ?

My package.json file is -

{
  "name": "yoke",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.18.0",
    "bootstrap": "^4.3.1",
    "config": "^3.1.0",
    "history": "^4.9.0",
    "jquery": "^3.4.1",
    "jwt-decode": "^2.2.0",
    "moment": "^2.24.0",
    "popper.js": "^1.15.0",
    "react": "^16.8.6",
    "react-bootstrap": "^1.0.0-beta.8",
    "react-dom": "^16.8.6",
    "react-router-dom": "^5.0.0",
    "react-scripts": "3.0.1",
    "serve": "^11.0.2"
  },
  "proxy": "http://localhost:4000",
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  }
}

Upvotes: 0

Views: 765

Answers (1)

aidden
aidden

Reputation: 543

I have just tried to do the same (I assume you've used an Azure App Service) and it works fine. Ensure that you have the contents of your build folder in the wwwroot folder itself by following this set of documentation: create-react-app in Azure App Service

Edit: It looks like your in case (Node Web App) you should set the default document as described in this article: https://blogs.msdn.microsoft.com/waws/2017/09/08/things-you-should-know-web-apps-and-linux/#NodeHome.

Put the index.js file in the wwwroot with the following contents:

var express = require('express');
var server = express();
var options = {
    index: 'index.html'
};
server.use('/', express.static('/home/site/wwwroot', options));
server.listen(process.env.PORT);

Edit2 (the part, omitted from the MS article): Then in your app's blade in Azure Portal open Advanced Tools and click "Go", Kudu web page will open. Click the "Bash" link in the top menu and run the following commands in the console:

npm install express

After the packages have been successfully installed, go to the Overview blade in the portal and restart your app service.

Upvotes: 2

Related Questions