Advanced Node and Express - Set up the Environment - Your client should connect to your server error

I am having a tough time determine what “server” I need to be using for this challenge. I tried both my application homepage on github and my callback URL, but still can’t pass the test. Could someone help me understand what server URL I should be using?

my code can be found on GLITCH

So if you’re talking about this line:
io.connect('https://glitch.com/@jpvajda/auth/github/callback');
I don’t think you need that URL because you are connecting to a socket hosted at the same URL as your app. You only need to pass a URL if it’s an external socket. So try it with no URL.

If it’s still not working…if I remember correctly from when I did this challenge…There were a number of things I had to do to get it set up correctly that weren’t specified in the instructions. Like connect to the database again, and get new CLIENT_ID and CLIENT_SECRET from Github. Unfortunately I can’t remember all of the details, but it was all the kind of stuff that the previous challenges went through. So check for errors in the console. And just see if you are missing anything.

1 Like

Thanks for the suggestions… I did remove the io.connect URL reference, and it still not working. I also tried creating a new CLIENT_SECRET and that also didn’t pass the test… so I’ll keep trying to figure this one out :slight_smile:

1 Like

Keep fiddling with it, that’s how I did it haha.

Also I needed to change the callbackURL for the GitHubStrategy in the auth.js file as well. They give a URL to some project, but it should be your app’s URL with “/auth/github/callback”.

1 Like

@stressstressstress I fixed that callback URL on the auth.js file, and when I click on the login with github link I get this console error:

Content Security Policy: The page’s settings blocked the loading of a resource at https://github.com/login/oauth/authorize?response_type=code&…da%2Fauth%2Fgithub%2Fcallback&client_id=08c1bd8f5f82b9f8f967 (“frame-src”) 

Is this a cors issue? I’ve added cors to my dependencies in the package.json file and added this to the server.js file. Am I missing something here to get the URL to be accessible from the project page?

const cors = require('cors');

app.use(cors());

I think the URL you need to use is for the project page itself, not the editor view or your Glitch profile.
https://fcc-node-express-env-jv.glitch.me

Use that plus ‘/auth/github/callback’ for the callback URL.

If you click “Show” then “In a New Window” your project should open to that URL.

1 Like

@stressstressstress That worked as I set that in the github application as the callback URL and also in the auth.js file, , it routes correctly to github for authorization, but the test still doesn’t pass… :frowning:

What challenge are you working on now?

@stressstressstress this one:

advanced-node-and-express/set-up-the-environment

@stressstressstress I figured it out! I didn’t realize there was a client.js file in /public and made my own in the root of the project, so once I discovered that, I added

/*global io*/
var socket = io();

to that file and it passed! Thanks for all your help here, I definitely appreciate it.

5 Likes

Glad you figured it out! These backend challenges have a lot of tricky parts to work through, so I’m happy to try to help.

1 Like