Forum Discussion
You do not have permission to view this directory or page.
- Apr 06, 2023
techieg4 FInally resolved it by unchecking the "Prepend root folder name to archive path" checkbox (see image below), which was zipping up everything within a "build" folder and deploying it as such. So, the website could only see the "build" directory in wwwroot, which triggered the error message since browsing to the url was trying to access this folder rather than the index.html that was supposed to be at the wwwroot.. Once I unchecked that checkbox, no more zipping up in the "build" folder and zipped files get deployed in wwwroot as it should. All is well!
techieg4 FInally resolved it by unchecking the "Prepend root folder name to archive path" checkbox (see image below), which was zipping up everything within a "build" folder and deploying it as such. So, the website could only see the "build" directory in wwwroot, which triggered the error message since browsing to the url was trying to access this folder rather than the index.html that was supposed to be at the wwwroot.. Once I unchecked that checkbox, no more zipping up in the "build" folder and zipped files get deployed in wwwroot as it should. All is well!
This helped me. Hope it helps you.
Add this to your web.config in the root of your project
<configuration>
<system.webServer>
<!-- indicates that the server.js file is a node.js application
to be handled by the iisnode module -->
<handlers>
<add name="iisnode" path="server.js" verb="*" modules="iisnode" />
</handlers>
<!-- adds server.js to the default document list to allow
URLs that only specify the application root location,
e.g. http://mysite.azurewebsites.net/ -->
<defaultDocument enabled="true">
<files>
<add value="server.js" />
</files>
</defaultDocument>
<!-- Ensure all errors are sent to the node.js application for better error handling -->
<httpErrors existingResponse="PassThrough" />
<!-- Ensure the Node.js application can handle all URLs -->
<rewrite>
<rules>
<rule name="NodeJS" stopProcessing="true">
<match url="/*" />
<action type="Rewrite" url="server.js" />
</rule>
</rules>
</rewrite>
</system.webServer>
</configuration>
create a server.js file and add the code below
const { createServer } = require("http");
const { parse } = require("url");
const next = require("next");
const dev = process.env.NODE_ENV !== "production";
const app = next({ dev });
const handle = app.getRequestHandler();
app.prepare().then(() => {
createServer((req, res) => {
const parsedUrl = parse(req.url, true);
handle(req, res, parsedUrl);
}).listen(process.env.PORT || 3000, (err) => {
if (err) throw err;
console.log("> Ready on http://localhost:3000");
});
});
finally in your package.json, edit your start script
"start": "node server.js"