You are not logged in.

#1 Yesterday 03:14:21

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

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 Yesterday 07:20:43

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

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 Yesterday 16:36:26

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

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 Yesterday 19:42:41

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

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 Yesterday 20:55:42

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

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 Yesterday 21:31:18

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

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 (Yesterday 21:32:31)

Offline

Board footer

Powered by FluxBB