0

I'm trying to use "www" in the domain http://www.nickjonas.nyc and I'm just getting 404 errors from Google's end. When you go to http://nickjonas.nyc, it works just fine.

Here is what my DNS looks like on GoDaddy:

enter image description here

Here is what it looks like in AppEngine settings:

enter image description here

Here is my app.yaml:

runtime: nodejs
env: flex

And here is my app.js:

// [START gae_flex_node_static_files]
'use strict';

const express = require('express');
const app = express();

app.set('view engine', 'pug');

// Use the built-in express middleware for serving static files from './public'
app.use('/static', express.static('public'));

app.get('/', (req, res) => {
  res.render('index');
});

// Start the server
const PORT = process.env.PORT || 8080;
app.listen(PORT, () => {
  console.log(`App listening on port ${PORT}`);
  console.log('Press Ctrl+C to quit.');
});

// [END gae_flex_node_static_files]
module.exports = app;
Nick Jonas
  • 1,197
  • 4
  • 13
  • 24

2 Answers2

0

I see that in your GoDaddy domain configuration, you are setting the CNAME alias for www of your domain. Something I could not see is if you also configured the www subdomain inside the App Engine custom domain mappings. The App Engine documentation points out that you must add the subdomains you would like to map during configuration, recommending to map the www subdomain:

  1. In the Point your domain to [project-ID] section, specify the domain and subdomains that you want to map.

We recommend mapping the naked domain and the www subdomain. You can add more subdomains if you need them. When you've added all the mappings you want, click Save mappings.

Your App Engine config screenshot does not show it, but it should appear as shown here with both the www subdomain and the actual domain in the list.

ErnestoC
  • 2,660
  • 1
  • 6
  • 19
  • What's strange is I don't see a way of adding the `CNAME` alias on the AppEngine side. The video you linked to [here](https://www.youtube.com/watch?v=iqAku7kveO8&t=910s) uses Google Domains which won't work with my top level domain (`.nyc`). – Nick Jonas Mar 10 '22 at 14:25
  • According to the documentation in my answer and this specific part of the [video](https://www.youtube.com/watch?v=iqAku7kveO8&t=623s), the `www` subdomain is to be added to the list when mapping your custom domains in the App Engine configuration. I noted that both of your URLs now open the page correctly, when yesterday I could see the 404 error. Did you figure out the cause of the error? – ErnestoC Mar 10 '22 at 21:21
  • It's now working due to a subdomain redirect, per @NoCommandLine's answer above. – Nick Jonas Mar 11 '22 at 00:06
  • You are right, it needs to be there as well, but I can't find a way of doing it / editing it. I'll mark his answer as a fix for now. – Nick Jonas Mar 11 '22 at 00:07
  • A different thing you could try regardless is to export your DNS records to GCP Cloud DNS, while keeping your GoDaddy domain. It might help you in routing your subdomains without hitting a 404 error. You can check this guide that does just [that](https://www.siteyaar.com/setting-up-google-cloud-dns-for-your-godaddy-domain/). – ErnestoC Mar 11 '22 at 22:54
0

There are at least 2 possible ways to remove the 404

  1. On Google App Engine Settings page, you will have to map both your naked and www domains to your project id i.e. repeat the steps you executed for what you currently display in your screen shot for the www subdomain. This will mean your pages will essentially be reachable via 2 urls. If you do this, you should tell Google which one to crawl by setting a canonical url. See documentation

  2. Second option is to keep what you currently have but then add domain forwarding in GoDaddy Settings to forward http://www.nickjonas.nyc to http://nickjonas.nyc. This means that if a user enters http://www.nickjonas.nyc in the browser, it would redirect them to http://nickjonas.nyc The advantage of this method is that you don't have the duplicate url issues associated with method 1.

NoCommandLine
  • 5,044
  • 2
  • 4
  • 15