最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

node.js - Unable to Access Strapi Admin Panel on Azure App Service After Deployment - Stack Overflow

programmeradmin3浏览0评论

I am deploying a Strapi project on Azure App Service. Here's what I have done so far:

I deployed the Strapi project using FTP and then ran the necessary commands (npm install, npm run build) in the Azure Kudu console.
After starting the project with npm run develop, the console shows that Strapi started successfully, and it provides a URL like http://localhost:8080/admin.
I also tried deploying the application via GitHub Actions, but the result was the same.

I updated the server.js file in my Strapi project to use the Azure default domain name (.azurewebsites) as the host, but when I try to access the Strapi admin panel through the browser using the Azure default domain, it does not work.

My question is:

How can I make the Strapi admin panel publicly accessible on Azure App Service?
Do I need to map localhost with the Azure default domain somewhere in the configuration?

Any help or guidance on this issue would be greatly appreciated.

Thank you in advance!

I am deploying a Strapi project on Azure App Service. Here's what I have done so far:

I deployed the Strapi project using FTP and then ran the necessary commands (npm install, npm run build) in the Azure Kudu console.
After starting the project with npm run develop, the console shows that Strapi started successfully, and it provides a URL like http://localhost:8080/admin.
I also tried deploying the application via GitHub Actions, but the result was the same.

I updated the server.js file in my Strapi project to use the Azure default domain name (.azurewebsites.net) as the host, but when I try to access the Strapi admin panel through the browser using the Azure default domain, it does not work.

My question is:

How can I make the Strapi admin panel publicly accessible on Azure App Service?
Do I need to map localhost with the Azure default domain somewhere in the configuration?

Any help or guidance on this issue would be greatly appreciated.

Thank you in advance!

Share Improve this question asked Jan 18 at 18:29 Arslan HanifArslan Hanif 233 bronze badges 3
  • can you please share the code that you've tried. – Sirra Sneha Commented Jan 18 at 18:44
  • I use the command npx create-strapi@latest my-strapi-project new project is created , I change the database to mysql and then, simply using ftp deploy the project to azure app service directory . I run commands like npm run install , npm run build and npm run start , after this strapi started successfully . but unable to open the strapi page on browser. – Arslan Hanif Commented Jan 18 at 21:18
  • hansif have you tried deploying it to azure app service via visual studio code extension? it worked perfectly fine for me. – Sirra Sneha Commented Jan 20 at 9:58
Add a comment  | 

1 Answer 1

Reset to default 0

I created a sample Strapi application and successfully deployed it to Azure Web App via GitHub actions.

Make sure you add publish URL in your env file

HOST=0.0.0.0

PORT=1337
PUBLIC_URL=https://<Azureappservice-domain>.azurewebsites.net

Also add PUBLIC_URL in server.js file

server.js:

export  default ({ env }) => ({
host:  env('HOST', '0.0.0.0'),
port:  env.int('PORT', 1337),
url:  env('PUBLIC_URL', 'https://<Azureappservice-domain>.azurewebsites.net')
app: {
keys:  env.array('APP_KEYS'),
},
});

Add the below start script to the package.json file, this helps the correct Strapi start command is executed to launch the application.

"start": "node node_modules/@strapi/strapi/bin/strapi.js start"

Complete package.json:

{
  "name": "strapisample",
  "version": "0.1.0",
  "private": true,
  "description": "A Strapi application",
  "scripts": {
    "build": "strapi build",
    "deploy": "strapi deploy",
    "develop": "strapi develop",
    "start": "node node_modules/@strapi/strapi/bin/strapi.js start",
    "strapi": "strapi"
  },
  "dependencies": {
    "@strapi/plugin-cloud": "5.8.0",
    "@strapi/plugin-users-permissions": "5.8.0",
    "@strapi/strapi": "5.8.0",
    "better-sqlite3": "11.3.0",
    "react": "^18.0.0",
    "react-dom": "^18.0.0",
    "react-router-dom": "^6.0.0",
    "styled-components": "^6.0.0"
  },
  "devDependencies": {
    "@types/node": "^20",
    "@types/react": "^18",
    "@types/react-dom": "^18",
    "typescript": "^5"
  },
  "engines": {
    "node": ">=18.0.0 <=22.x.x",
    "npm": ">=6.0.0"
  },
  "strapi": {
    "uuid": "8b858a84-0904-4cc4-ae57-38d0cc99d37a"
  }
}
  • Configure the below startup command in the configuration section of your App service.
pm2 serve /home/site/wwwroot/build --no-daemon --spa

  • Also add required environment variables to your Azure App Service environment variable section.

After doing above changes I've successfully deployed the app to Azure Web apps via GitHub actions.

发布评论

评论列表(0)

  1. 暂无评论