Issue Deploying Remix in NX monorepo - Page not found

I have converted a project in an NX mono-repo from CRA to Remix. I can build and run it locally with no problems. However, no matter what I do at deploy, I’m just getting the Page Not Found error.

The site is : (that is a branch deploy - main URL is still live with the old app)

In NX, I have the netlify.toml at the top level. It looks like this:

command = "yarn build:remix"
functions = "netlify/functions"
publish = "apps/remix/public"

command = "remix watch"
port = 3000

from = "/*"
to = "/.netlify/functions/server"
status = 200

for = "/build/*"
"Cache-Control" = "public, max-age=31536000, s-maxage=31536000"

I have tried everything I can find online and in other tickets here and can’t get past this.

Hi there,

Thanks for reaching out. I know you state you have tried everything you have found online-- did you see this guide yet? This is the best place to start for “Page Not Found” issues.

If you are still seeing issues after following the troubleshooting steps in there, please check out this Support Guide as well. It outlines all of our build and deploy resources and will get you on the right track :slight_smile:

If none of the above resources help, please write back and let us know. We will need to see your repo in addition to your site link.

I actually ended up getting help from the Remix community on this one. The missing piece for me was this:

directory = “/apps/PROJECTNAME/.netlify/functions-internal”

Thanks for coming back and sharing! This will definitely be beneficial for future Forums members who encounter something similar.

Happy building :rocket:

Hi Hillary - so, I’m continuing this thread as I’m not sure if this is resolved. This is a weird one. When I deploy to develop now, and it auto-deploys a dev branch, that works fine. If I merge to main locally and push, and that triggers a production build, I’m still getting the page not found error. I can push the develop build to production via your uI and that works fine - what would cause something like that to happen?

It looks like the redirect that you’ve added:

is being detected, but not triggering.

That’s for this deploy: Netlify App, but it’s working for this one: Netlify App

That’s the cause of problem here. I don’t think you’ve done anything wrong - this appears to be something weird on our end. I’ll confirm with the devs as to why the redirect is not triggering and let you know as we have more details.

Oh wait, the problem is happening because of: Netlify App

The functions directory that you’re setting seems to be invalid. Thus, that function is never deployed, and thus it’s a 404.

But, I don’t understand why this is happening? I’m pretty sure that directory is build in the build process. I’m talking about pushing the EXACT same code to two branches - one deploys to your ‘temporary release’ and one to a ‘production release’. The temporary builds that directory just fine and works. The production doesn’t

Is there an internal setting that might impact this, seeing that the code is identical?

Justin Handley

Hi, @justinhandley. All the settings I can see identical for both builds but only one says the directory is missing.

It might help to create the directory in the repo. Would you please double check that the directory exists in the production branch?

There is a “brute force” debugging method as well which is to print the contents of that directory to the build logs after the build command completes.

The current build command is this:

yarn build:remix

To log the contents of that directory, you can use the “logical AND” and the command tree to log the directory contents. The “logical AND” is important as tree will almost alway return a zero exit code. If you don’t use the “logical AND” it will mean that all builds, even builds with errors, will succeed. That would publish builds with errors and we don’t want that happening.

Using the “logical AND” with tree the new build command might look like this:

yarn build:remix && tree apps/remix/.netlify/functions-internal

That is saying:

  • Only if the build itself succeeds, then run this tree command to print the filenames and directories under apps/remix/.netlify/functions-internal.

This will help us to determine if the directory is indeed missing or not. If it is missing, then debugging why it is missing is the next step. If the directory is there, then something else is happening. Either way, we will have more information than we do now.

Would you be willing to please try that?

OK, actually, I figured it out.

This relates to the fact that it is an NX project connected to NX Cloud, which is a remote caching service that helps speed up builds.

If I disconnect from NX Cloud it works fine - I have followed up with their support - thank you for your time on this.


1 Like

Thank you so much for coming back and letting us know! Glad everything is working now.