Next.js Discord

Discord Forum

Subdirectory routing does not get the css or the ts/js so the page is plain HTML ex: foo/bar/page.ts

Answered
Asiatic Lion posted this in #help-forum
Open in Discord
Asiatic LionOP
So I'm creating a generic marketing site for a customer and I'm having some issues with subdirectory routing

As far as I'm aware the routing should be as follows.
In the app folder I have a page.tsx

When I want to make a subroute to for ex: localhost:8080/foo/bar, I should create 2 subdirectories.
Foo and Bar. Inside bar I should create a page.tsx and next should handle the routing from there.

You can see in my first screenshot that I have done exactly that with the producten/afsluitingen/page.tsx file.

The problem now is apparent in my second screenshot, IE next routes all requests through producten and so nothing loads correctly anymore

My nextjs is in screenshot number 3.

What am I doing wrong?
Answered by Asiatic Lion
I have fixed this myself but not using the assetprefix anymore..
I also deleted all relative paths and urls but now ofcourse my app just doesnt load correctly on GitHub pages because of the name.github.com/repo-name that is the domain name. NextJS cant go to public or whatever directory now because they all are broken.
I'm off to investigate how to properly deploy this on pages without a custom domain and without relative pathing (or without breaking it at the minimum)
View full answer

1 Reply

Asiatic LionOP
I have fixed this myself but not using the assetprefix anymore..
I also deleted all relative paths and urls but now ofcourse my app just doesnt load correctly on GitHub pages because of the name.github.com/repo-name that is the domain name. NextJS cant go to public or whatever directory now because they all are broken.
I'm off to investigate how to properly deploy this on pages without a custom domain and without relative pathing (or without breaking it at the minimum)
Answer