hanford / next-offline

make your Next.js application work offline using service workers via Google's workbox
https://github.com/hanford/next-offline
1.59k stars 111 forks source link

run dev problem when use iis and next-offline #222

Open hmz22 opened 4 years ago

hmz22 commented 4 years ago

Hi Dears. I have problem when run project in iis

this my next.config.js

const path = require("path"); const nextOffline = require("next-offline");

module.exports = nextOffline({ generateInDevMode:true, workboxOpts: { swDest: path.join(__dirname, "public/service-worker.js") } });

and have web.config when run give me this error: iisnode encountered an error when processing the request.

HRESULT: 0x2 HTTP status: 500 HTTP subStatus: 1002 HTTP reason: Internal Server Error You are receiving this HTTP 200 response because system.webServer/iisnode/@devErrorsEnabled configuration setting is 'true'.

In addition to the log of stdout and stderr of the node.exe process, consider using debugging and ETW traces to further diagnose the problem.

The last 64k of the output generated by the node.exe process to stderr is shown below:

(node:10288) [DEP0005] DeprecationWarning: Buffer() is deprecated due to security and usability issues. Please use the Buffer.alloc(), Buffer.allocUnsafe(), or Buffer.from() methods instead. (node:10288) UnhandledPromiseRejectionWarning: Error: EPERM: operation not permitted, open 'C:\projects\next-demo\node_modules\next-offline\register-sw-compiled.js' (node:10288) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:10288) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

Can anyone help me?

hmz22 commented 4 years ago

I solved this issue. just need add this line to web.config: I solved this issue just need add this line to your web.config

<configuration>
   <system.webServer>
    ...
     <iisnode node_env="production" />
     <httpErrors existingResponse="PassThrough" />
    ...
   </system.webServer>
</configuration>