NextJS hosting on Firebase: how to respond with status 404 on a custom 404 page - next.js

Any idea how to make a custom 404.js also return an error code 404 rather than 200?
Hosting is on Firebase hosting so no access to .htaccess or Apache or anything like that.
The trouble is Firebase hosting only allows to rewrite source ** to an html file like /404/index.html which by default returns 200 rather than 404, which is a bad SEO experience.
So the question becomes if Firebase and/or Nextjs has any way for an html file to return a status 404? tried httpEquiv, didn't work, still 200...

Related

Gatsby redirects

External sources beyond my control link to pages like: somedomain.com/Some-Path which results in a 404 because the path is case sensitive.
I'm getting a "too many redirects" error in production (it works fine local) when using the following:
const url = '/*'
createRedirect({
fromPath: url,
toPath: url.toLowerCase(),
})
For context I'm hosting with Gatsby Cloud and using their plugin gatsby-plugin-gatsby-cloud
The expectation is that somedomain.com/Some-Path will redirect to somedomain.com/some-path

Failed to load resource: the server responded with a status of 403 - WordPress Website

I migrated a wordpress website to a new host, i made some edit to the wordpress page and tried to save the page. It was giving me the error below when i used google chrome console to debug the issue
“Failed to load resource: the server responded with a status of 403 ()”
with the route “wp-admin/admin-ajax.php:1”
After trying all the solutions outlined below, so i was able to fix it by using the Solution 6.
403 forbidden means that your browser isn’t able to load the scripts up because your server isn’t allowing it. This is a hard one to solve. Because anything could be blocking the server. Hence 403 forbidden error is very vague, the error log may give you clue.
Solution 1 – Most likely this is a server permissions/ownership issue. If its a permission issue, it may tell you which file has incorrect permissions, so ask your host what’s going on. If you are using cPanel, the following tutorial has more information about the error log in cPane: How to view cPanel Error logs
Solution 2 – If the problem is file permissions, you can follow the steps in the below article to learn how to modify your file permissions: How to change file permissions within cPanel https://codex.wordpress.org/Changing_File_Permissions
Solution 3 – Another possible cause could be a corrupt .htaccess file. Also check your .htaccess files for anything strange.
Solution 4 – make sure your server settings are not overriding the .htaccess file.
Solution 5 – Another possible cause could be changes to the server settings (accidental or otherwise). Check with your hosting provider.
Solution 6 -Last but not the least solution, disable mod security for that domain.

Netlify redirect rule breaking NextJs

I'm building a NextJs site hosted on Netlify. The idea of the site is that it will be a gradual replacement of another site built on older tech, so the NextJs site will return a page if it has it otherwise the request will be re-written to the older site.
I have a Netlify redirect rule setup in the netlify.toml file as follows:
[[redirects]]
from = "/*"
to = "http://old-site-url/:splat"
status = 200
force = false
For the most part this works. If I add a static file to Netlify, then it is returned, the homepage in NextJs is returned, and pages I haven't yet created get rewriten to the old sites url. However every call to anything in the /_next/ folder return a 500 error.
Remove the redirect and it all works again.

Vue Website give 404 error when i try to access with website.com/pagename

I am learning vue and firebase.I just deployed my app on netlify server after build.All ok but i try to directly access my site with page name like this is my app To Vue.It have 5 pages signin, signup, home, global, profile and 404. My app open and work correctly when i open home like like https://vuefire-auth.netlify.app but i try to open with page name like https://vuefire-auth.netlify.app/signup netlify give me error.How to handle it?
Thanks in advance.
Create a _redirects file in your project with the following content:
/* /index.html 200
This rule ensures that every path successfully resolves to index.html and the client has full control over the routing logic.
Read article: Creating better, more predictable redirect rules for SPAs

Automatically redirect URLs generated by Vercel's production deployments to custom domains

If you are deploying to Vercel for production and you have set up a custom domain, you can access the same page from the following three URLs.
1. https://[vercelProjectName]-[vercelUserName].vercel.app
2. https://[vercelProjectName]-[deployId]-[vercelUserName].vercel.app
3. https://[myDomain].com
Furthermore, all of them exist independently, without being redirected to a custom domain.
However, it seems that URLs in 1. are not registered with search engines, so you can leave them alone.
Are Vercel Preview Deployments indexed by search engines? – Vercel Docs
Still, the URLs for 2. and 3. are duplicated.
Is there any way to redirect the user to URL 3. when accessing URL 2. ?
Detail
I'm deploying an application consisting of Next.js, Firebase and Sentry to Vercel.
In addition, I use Firebase App Check to make sure that Firebase storage cannot be manipulated by anyone other than authorized domains.
And yesterday, when I installed Sentry, I had the following error in URL2.
#firebase/app-check: FirebaseError: AppCheck: Fetch server returned an HTTP error status. HTTP status: 403. (appCheck/fetch-status-error).
The URL in 2. is not allowed by App Check, which is probably causing the above error.
Also, the above error occurs once per 15 to 30 minutes.
The error is caused by the following execution environment.
I don't know if it's Google's crawler or what, but there's something running around.
I want to redirect this guy running around who came to URL 2. to URL 3.
The URLs in 1. 2. 3. have canonical set in the head as shown below.
<link rel="canonical" href="https://[myDomain].com">
However, the noindex is not included in the head tags of pages 1. and 2.

Resources