Skip to content

404 Cannot GET / on routes #140

@kellyjjrusk

Description

@kellyjjrusk

I have routes in my Node/Express app running on the D: drive of a Windows Server running iisnode. The main page and the swagger UI page load via their respective get or app.use but not the JS files inside of the routes. (noting that the flat HTML or Swagger UI is different than a .js file).

It gives me a 404 when trying to execute the API routes. I have detailed this in my StackOverflow post here: https://stackoverflow.com/questions/77694208/iisnode-returns-404-for-routes-but-node-returns-routes

The app runs as intended/no issues if I launch Node and do an NPM start from the directory (I have the IIS site stopped when I do this) but when I run it through IIS it says it "Cannot GET /" with a 404.

I suspect it may be the path to the routes, but I tried moving everything to the C: drive under nodejs and running the app from there, but no luck.

In the iisnode logs, I see the following when I try to execute a route:

Application has thrown an uncaught exception and is terminated:
Error: Cannot find module './routes/api1.js'
Require stack:
- D:\myapp\server.js
- C:\Program Files\iisnode\interceptor.js
    at Module._resolveFilename (node:internal/modules/cjs/loader:1143:15)
    at Module._load (node:internal/modules/cjs/loader:984:27)
    at Module.require (node:internal/modules/cjs/loader:1234:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (D:\myapp\server.js:11:18)
    at Module._compile (node:internal/modules/cjs/loader:1375:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1434:10)
    at Module.load (node:internal/modules/cjs/loader:1206:32)
    at Module._load (node:internal/modules/cjs/loader:1022:12)
    at Module.require (node:internal/modules/cjs/loader:1234:19)

Here is where I reference the routes in my app:

// Require Routes
var api1 = require('./routes/api1.js')
var api2 = require('./routes/api2.js')

If I inspect the page, it gives the error as coming from actions.js:

Could not load content for webpack://SwaggerUIBundle/src/core/plugins/spec/actions.js (Fetch through target failed: Unsupported URL scheme; Fallback: HTTP error: status code 404, net::ERR_UNKNOWN_URL_SCHEME)

I believe last actions.js error is from swagger because when I call the URL direct (not the "Try It Now" button in Swagger) it produces the normal errors of:

Cannot GET /api1

http://localhost/api1 404 (Not Found)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions