Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

404 Cannot GET / on routes #140

Open
kellyjjrusk opened this issue Dec 21, 2023 · 0 comments
Open

404 Cannot GET / on routes #140

kellyjjrusk opened this issue Dec 21, 2023 · 0 comments

Comments

@kellyjjrusk
Copy link

kellyjjrusk commented Dec 21, 2023

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)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant