I was trying to deploy an app that uses Next.js on the frontend (with some getStaticProps
function) and a custom express/node.js backend on azure. it uses MySQL as well (but I don't think that's related to the issue im having). The problem is that when I deploy it on azure I get "You do not have permission to view this directory or page." on the web page. My express file which contains all the routes and requests is in a folder named server and the file itself is called index.js
. I also have a web.config file which looks like this:
<configuration>
<system.webServer>
<handlers>
<add name="iisnode" path="server/index.js" verb="*" modules="iisnode" />
</handlers>
<rewrite>
<rules>
<rule name="NodeServer" patternSyntax="ECMAScript" stopProcessing="true">
<match url="server/index.js" />
<action type="Rewrite" url="server/index.js" />
</rule>
<rule name="NextJsRouting" patternSyntax="ECMAScript" stopProcessing="true">
<match url="^(.*)$" ignoreCase="false" />
<conditions logicalGrouping="MatchAll">
<add input="{REQUEST_FILENAME}" matchType="IsFile" negate="true" />
<add input="{REQUEST_FILENAME}" matchType="IsDirectory" negate="true" />
</conditions>
<action type="Rewrite" url="server/index.js" />
</rule>
</rules>
</rewrite>
<iisnode nodeProcessCommandLine=""C:\Program Files\nodejs\node.exe"" />
</system.webServer>
</configuration>
and I have a iisnode.yml
file which looks like this:
nodeProcessCommandLine: "node server/index.js"
the package.json
file looks like this:
{
"name": "endelig",
"version": "0.1.0",
"private": true,
"scripts": {
"dev": "nodemon server/index.js",
"build": "next build",
"start": "next start",
"lint": "next lint"
},
"dependencies": {
"@next/font": "13.1.6",
"@stripe/react-stripe-js": "^2.1.0",
"@stripe/stripe-js": "^1.52.0",
"bcrypt": "^5.1.0",
"cookie-parser": "^1.4.6",
"dotenv": "^16.0.3",
"express": "^4.18.2",
"jsonwebtoken": "^9.0.0",
"micro": "latest",
"micro-cors": "latest",
"mysql": "^2.18.1",
"next": "^13.1.6",
"nodemailer": "^6.9.1",
"react": "18.2.0",
"react-dom": "18.2.0",
"stripe": "^11.17.0"
}
}
the jsconfig.js
file looks like this:
{
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@/*": ["./*"]
}
}
}
I have configured all the env variables as well in the web app in azure as well btw. I've been stuck for a few days and eny help would be greatly appreciated.
Deploying it on azure. Failed and got (You do not have permission to view this directory or page). on the web page