You are not logged in.

#1 2024-11-06 03:14:21

Vynro
Member
Registered: 2024-10-04
Posts: 7

Web Development (.NET 8, Node.js) some .js files are returning 404.

Hey Guys, I'm scratching my head here and running out of things to check.

This issue is persistent between 2 arch linux machines (laptop and desktop) and I'm unsure What other things I could try. When I am developing websites (for work, or personal) I need to access localhost alot. e.g

http://localhost:3000

Some resources load perfectly fine, linke the main index page in my dotnet application. But when I go to a page that needs to load a lot of .js files, the network tab in firefox returns a bunch of 404's for most of my files. This site works properly on windows and mac as well. When trying to run my node.js application with Remix.js, upon first visit of the page, the remix.js server actually crashes completely. Due to the nature of this being spread between 2 arch linux installations, I'm beginning to think it's got to do something with my networking or something.

I have:

  • NetworkManager

  • dnsmasq

installed and configured.

My /etc/hosts file looks like this:

# Static table lookup for hostnames.
# See hosts(5) for details.
127.0.0.1 localhost
::1 localhost
127.0.1.1 shattered-star

I have disabled ipv6 on my ethernet connection thinking it may be some issues with that. I have checked to make sure I don't have ahavi running as I've read that could cause issues as well. I have made sure firefox is not using any DNS over HTTPs settings and is using the system default. If I curl the website, the index pages and such return, but not the resources that fail to load in firefox. If I dig my localhost, it returns. I can verify that processes are running on port 3000 when the webservers are running. I am running out of things to try, I'm hoping someone can point me in the right direction! please let me know if you need anymore information.

Offline

#2 2024-11-06 07:20:43

seth
Member
Registered: 2012-09-03
Posts: 58,659

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

Due to the nature of this being spread between 2 arch linux installations

What does that mean?

In general please don't paraphrase, https://bbs.archlinux.org/viewtopic.php?id=57855

curl -v -L http://url/path/to/missing/file.js

404 generally means that the file doesn't exist, either you're asking the wrong http server or the http server is misconfigured or there's a typo/mismatch in the filename.
You get different errors if there's no http server or you're calling a non-existing domain or IP.

Offline

#3 2024-11-06 16:36:26

Vynro
Member
Registered: 2024-10-04
Posts: 7

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

I may not have explained it properly. My apologies.

Due to the nature of this being spread between 2 arch linux installations

This behaviour is happening on 2 separate Arch Linux Installations. It's also persistent across 20-30+ reinstalls of archlinux. (I have reinstalled numerous times, while I figure out all the ins and outs of setting up my system. I could probably not do that, But I've broken it enough times and have been "close enough" to a fresh install that I find it easier to re-install and tweak with the new things I've learned, as I want my archlinux system to be "perfect" in my eyes).

This behaviour is only exhibited on my archlinux installations. The default installation of the .NET SDK on Windows, Mac, and even Ubuntu work exactly as expected - Meaning I can clone my code to the machine, throw my appsettings.json into the folder and

dotnet run

and I'm off to the races testing my code. Arch Linux is also the first time I've seen where using bun and Remix.js's built in server for development crashes on the first visit of the site on localhost.

Due to this behaviour only being present on my archlinux installations and not the other operating systems I've tried running it on, I believe it is to do with how my arch install is setup. With the default installation of dotnet sdk working out of the box on other distros, I've never really had to configure the kestrel server that serves the files, So I haven't begun diving into tuning that just yet - as I've been focussed on what might be causing it to fail on arch.

Here is as much info as I can provide:

Output in Firefox Console

GET
http://localhost:3000/Ribbon/icons/measure.png
[HTTP/1.1 404 Not Found 1ms]

output of curl with ipv6 still enabled

curl -v -L http://localhost:3000/Ribbon/icons/measure.png
* Host localhost:3000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:3000...
* Connected to localhost (::1) port 3000
* using HTTP/1.x
> GET /Ribbon/icons/measure.png HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.10.1
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 404 Not Found
< Content-Length: 0
< Date: Wed, 06 Nov 2024 16:19:45 GMT
< Server: Kestrel
<
* Connection #0 to host localhost left intact

Output of curl with ipv6 disabled at the kernel level

* Host localhost:3000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying 127.0.0.1:3000...
* Connected to localhost (127.0.0.1) port 3000
* using HTTP/1.x
> GET /Ribbon/icons/measure.png HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.10.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 404 Not Found
< Content-Length: 0
< Date: Wed, 06 Nov 2024 16:28:17 GMT
< Server: Kestrel
< 
* Connection #0 to host localhost left intact

The measure.png does exist in the wwwroot folder of my project.

The output from DIG on localhost

; <<>> DiG 9.20.3 <<>> localhost
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 3888
;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 0

;; QUESTION SECTION:
;localhost.			IN	A

;; ANSWER SECTION:
localhost.		10	IN	A	127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.1#53(127.0.0.1) (UDP)
;; WHEN: Wed Nov 06 09:32:13 MST 2024
;; MSG SIZE  rcvd: 43

The output of curling just http://localhost:3000

* Host localhost:3000 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying 127.0.0.1:3000...
* Connected to localhost (127.0.0.1) port 3000
* using HTTP/1.x
> GET / HTTP/1.1
> Host: localhost:3000
> User-Agent: curl/8.10.1
> Accept: */*
> 
* Request completely sent off
< HTTP/1.1 200 OK
< Content-Type: text/html; charset=utf-8
< Date: Wed, 06 Nov 2024 16:33:19 GMT
< Server: Kestrel
< Transfer-Encoding: chunked
< 

<!DOCTYPE html>

(I omitted the actual content for privacy reasons)

Being able to reach some resources on localhost, vs others getting 404 is starting to get frustrating. I've never had to modify the kestrel server on a linux system to get it to serve the pages properly, and I don't know where to check next with this issue for arch linux.

Offline

#4 2024-11-06 19:42:41

seth
Member
Registered: 2012-09-03
Posts: 58,659

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

But is "wwwroot" also the actual root of the responding server?
What if you move measure.png directly into "wwwroot" and try to access that file via http? Where exactly (absolutel path) is "wwwroot" located?
And how exatly did you install the kestrel server.

This isn't any kind of network error, but either the kestrel server is handing out bogus error codes (and this is actually eg. 403) or you're (most likely) placing files into the wrong location.

You can btw. "curl -v -L http://localhost:3000/Ribbon/icons/measure.png > /dev/null" to redirect the actuall file into /dev/null, we only care about the stderr from curl.

Offline

#5 2024-11-06 20:55:42

Vynro
Member
Registered: 2024-10-04
Posts: 7

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

I setup the kestrel sever with the following commands:

sudo pacman -S dotnet-sdk aspnet-runtime

Then I execute the command:

dotnet run projectname.csproj

The `wwwroot` folder is in my project folder `~/home/user/Documents/GitHub/project/, next to the csproj.

This project structure works on Ubuntu normally with a simple dotnet run command. I am not moving or placing files anywhere, I just git cloned the project, and run the dotnet command like I would on any other operating system I develop on. I find it interesting that I would need to do some extra configuration with the .NET 8 sdk to get kestrel to behave the same way that it behaves on windows, mac, and Ubuntu - especially since it's linux native for cross platform development. I'm ready to configure it if needed, I just hadn't anticipated that it would be this much of a pain to just use the sdk. This also Isn't the only webserver that is misbehaving, my React.js projects also seem to have issues with localhost, where node.js crashes completely when visited from the browser.

Also, thank you for your help thus far! Please let me know if I should do anything further for diagnosing.

Offline

#6 2024-11-06 21:31:18

seth
Member
Registered: 2012-09-03
Posts: 58,659

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

seth wrote:

What if you move measure.png directly into "wwwroot" and try to access that file via http?

Can you access any other, specific files in ~/home/user/Documents/GitHub/project/wwwroot this way?

Are you using the same dotnet version across all systems?
https://github.com/dotnet/aspnetcore/is … -665220066
Apparently the API was subject to random changes in the past…

Edit: it might help to just have the application print the wwwroot, https://www.aspsnippets.com/Articles/30 … root-path/

Last edited by seth (2024-11-06 21:32:31)

Offline

#7 2024-11-07 08:43:20

dalu
Member
Registered: 2014-04-16
Posts: 96

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

You mention remix.js.
What does remix have to do with the dotnet project?
What is listening on port 3000?
Do you not have access logs, to see what's happening on the server side when you get those 404s client side?
Which project is supposed to serve those js files? Who does the routing?
Can you do a

tree -I node_modules -d

inside the root dir of the project/s listening on port 3000?

Offline

#8 2024-11-07 16:11:01

Vynro
Member
Registered: 2024-10-04
Posts: 7

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

dalu wrote:

You mention remix.js.
What does remix have to do with the dotnet project?
What is listening on port 3000?
Do you not have access logs, to see what's happening on the server side when you get those 404s client side?
Which project is supposed to serve those js files? Who does the routing?
Can you do a

tree -I node_modules -d

inside the root dir of the project/s listening on port 3000?

Hey dalu, I mention remix.js because when I launch my remix.js project (seperate project,  unrelated to dotnet) I also observe similar behaviour. Sometimes the remix.js server straight up crashes, other times, it will render my layout, but none of the bodies of my pages, returning a 404. like the dotnet project, it works on ubuntu, Mac and Windows.

Back to dotnet:

I've put the server into 'diagnose' and 'debug' verbosity, but it doesn't return or indicate anything going wrong with the files not being loaded. Last night I tried re-installing arch using archinstall just in case that script added a package or setup the networking properly compared to the dozens of installations I've tried, and unfortunately the same behaviour occured on a completely fresh archinstall.

From what I'm observing, My arch installations just really don't like serving up certain files from localhost, regardless of what type of webserver it's using (remix.js, dotnet).

Offline

#9 2024-11-07 16:24:16

V1del
Forum Moderator
Registered: 2012-10-16
Posts: 23,174

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

Can you check the file permissions of those resources? Are you running the services as another than your user and they might literally not have access or are the files r perms for "others" distinctly different/different owners especially if you copied them from multiple systems?

Also general disclaimer... this is likely some difference in configuration between the working and the not working system. Reinstalling the not working system resulting in the same not working configuration where we've not yet ruled out the relevant differences will expectedly result in the same condition.

Last edited by V1del (2024-11-07 16:26:16)

Offline

#10 2024-11-07 16:34:35

Vynro
Member
Registered: 2024-10-04
Posts: 7

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

V1del wrote:

Can you check the file permissions of those resources? Are you running the services as another than your user and they might literally not have access or are the files r perms for "others" distinctly different/different owners especially if you copied them from multiple systems?

Also general disclaimer... this is likely some difference in configuration between the working and the not working system. Reinstalling the not working system resulting in the same not working configuration where we've not yet ruled out the relevant differences will expectedly result in the same condition.


Hey V1del, Thanks for you're reply!

I have run

sudo chmod -R 777 project/

on the affected project directories to try and rule out file permission issues. The same behaviour occurs with those permissions. I am running the webservers (dotnet run) and (bun run dev) as my logged in user, without sudo. Yes, I figured the results would be similar on a re-install. While I'm not new to linux, I've only been an arch linux user for a few months, and while I've been learning/tuning my system, I tend to reinstall the system to try new configurations and tweaks to get the system to where I want it to be, and have learned a tonne and almost have a configuration I like. The last piece of the puzzle is making my dev environment work for work ha. That's why I tried an archinstall as I've done tonnes of manual installations over the last few months, I thought maybe the automated installation might set some things correctly that I perhaps missed, and I could look into the configuration changes the automated install made compared to my manual installations and potentially find the cause.

Offline

#11 2024-11-07 18:32:44

seth
Member
Registered: 2012-09-03
Posts: 58,659

Re: Web Development (.NET 8, Node.js) some .js files are returning 404.

arch installations just really don't like serving up certain files from localhost, regardless of what type of webserver it's using

Nonsense. Try nginx.
This has nothing to do w/ the OS or your installation or http or the localhost etc.

1. Unless kestrel is complete FUBAR, 404 means eactly that: you're trying to access a file that does not exist It is NOT a permission error (that's 403) nor a server error (those are all 500)
2. what are "certain files"? Can you acces any other *specific* file inside the concerned wwwroot directory?
3. Is this maybe a case sensitivity issue? What filesystem is your $HOME ? Does it work w/ a wwwroot under /tmp ?
4.

Sometimes the remix.js server straight up crashes, other times, it will render my layout, but none of the bodies of my pages, returning a 404.

Does that mean the behavior is non-deterministic? The *same* remix.js will sometimes result in 404 and sometimes hand out the file? Where's the "layout" (css) located (use the webinspector)? Same path?
5. could you print out the wwwroot from the script?
6. last resort:

strace -f -tt dotnet run projectname.csproj 2>&1 | grep -i wwwroot

Offline

Board footer

Powered by FluxBB