Page not loading & API doesn't work

PLEASE help us help you by writing a good post!

  • We need to know your netlify site name. Example: gifted-antelope-58b104.netlify.app
  • DNS issues? Tell us the custom domain, tell us the error message! We can’t help if we don’t know your domain.
  • Build problems? Link or paste the FULL build log & build settings screenshot
  • Did you try Ask Netlify, our generative AI chatbot, before posting? It pulls info from Support Guides and recent solved forums posts.

The better the post - the faster the answer.

This is the package.json file :
{
“name”: “news-app”,
“version”: “1.0.0”,
“description”: “”,
“scripts”: {
“start”: “parcel index.html”,
“build”: “parcel build index.html --dist-dir ./dist”
},
“author”: “”,
“license”: “ISC”,
“dependencies”: {
“parcel”: “^2.11.0”
}
}

One of the problems i have with the site that just recently became a problem is that when you load up my site, everything works fine, but when you click on Create an account, before it used to redirect you to a login/signup page, not it shows that the page doesnt exist, locally it works fine tho.

Second problem is, when you login (locally in this case cuz login doesnt work on netlify right now) you get access to go to the News page, thats a clone of Google news, anyways, at the very start of this project, the API worked fine, news were appearing perfectly, but as i added more things to the site and more API calls, they just stopped working, Api would always return that the response is OK but it would still not show the news on the website. API in question is News API (https://newsapi.org/)

My sites link is: newsly-murga.netlify.com,

Site deploys fine, theres no errors in the deployment process, as ive mentioned before, the login page just recently stopped working, after i did some work with js to make the site responsive.

Again, site is completely fine locally.

Maybe im using a bad build command? The only thing i used for this site is vanilla js and parcel. The parcel build command i used is the same one from my other projects, but maybe it doesnt work here, im not educated enough in that case.

(5 minutes later) I just checked the deployment message from netlify, or the dist folder that it shows when it deploys the site, and i can not see the login html file in there anywhere, why did it remove the file?

1 Like

Try running your Build command locally, not your Develop command.

So try npm run build && npx serve -s dist

If your build differs from your develop, then this will reveal it.

Netlify won’t have removed anything, your build likely didn’t create the file for whatever reason.

Only thing I might add to Nathan’s excellent suggestion is to check for and remove any existing local build/output directory first as this will better imitate building on Netlify.

I dont think i have a develop command, i just right click the file and go to a local server, where the site runs fine, and ive done npm run build and npx serve -s dist.

I figured its not a problem with Netlify, the build completely ignores my login js css and html files, along with the data.js file, so basically like half of the files are completely ignored. After doing npx serve -s dist, its the same problem, i cant open the login page, after clicking on the login page, i do get some messages that ill share here, i have no idea what any of it means, im a complete newbie sorry.

You do, however in your case it would be npm run start as per your package.json:

"scripts": {
"start": "parcel index.html",
"build": "parcel build index.html --dist-dir ./dist"
},

Ultimately I just meant to ensure you’re comparing “exactly the same thing as is happening on Netlify”.

It’s extremely common for people to say “it works locally”, believing that confirms a Netlify issue, when they don’t quite understand their own project and are comparing two different things.

It’s most likely Parcel doesn’t work how you believed it worked.

Parcel doesn’t just copy the files you have into the dist it crawls them for references etc, and for whatever reason it doesn’t know you need the login page.

As per your Build command your one entry file is index.html

Notice how in the log it does show it has output newsPage.html

Using view source on the page you have deployed I can see links that reference /newspage:

But there are no links that reference /login-page.
In fact, the word login cannot be found at all:

Searching the page there is one, but that means you’re generating it at runtime with some JavaScript, and that it was probably impossible for Parcel to spot:

image

Which is confirmed by checking the JavaScript:

That’s correct, Netlify is just running your build and deploying what you’ve told it to.

In this case your build isn’t producing what you need, so you need to fix your build accordingly.