Quality Assurance Projects - Sudoku Solver

Tell us what’s happening:
Fail in submission of link in fcc solution page because failed to fetch url

Hi!

Can please check why my link below is not accepted?

I’ve followed the replit code to apply secrets for NODE_ENV and PORT. The console shows everything is ok and passed all the test.

`https://replit.com/@vlchung/boilerplate-project-sudoku-solver`

Your project link(s)

solution: boilerplate-project-sudoku-solver - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Linux; Android 9; vivo 1904) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.101 Mobile Safari/537.36

Challenge: Quality Assurance Projects - Sudoku Solver

Link to the challenge:

That is not the correct link to submit to FCC. That’s the link to your project code.
You need the live project url, which is above the Webview window (highlighted here):

I had submitted the link below but still not accepted.

`https://boilerplate-project-sudoku-solver.vlchung.repl.co`

The problem with replit is to hide the Port and the Node_env value, the code used in Replit is not accepted in the FCC submission solution link page.

const PORT = process.env.PORT || 3000
process.env.NODE_ENV = 'test'

In replit, the code to hide the values is

const PORT = process.env['PORT']
process.env['NODE_ENV'] = 'test'

Still cannot figure out how to solve this problem

There are two simple fixes which will pass this project for you.

  1. You need to store your environment variables in your Secrets tab in Replit. Save the two variables there and then delete the sample.env file altogether.

  2. The tests crash the repl, so add the following code at the very bottom of your 2_functional-tests.js file.

after(function() {
  chai.request(server)
    .get('/')
  });

This code restarts the repl, allowing your project to pass on FCC.

Also, when using your env variables in your code, either format is fine:

process.env['PORT']
process.env.PORT

The issue was that the variables weren’t stored in your Secrets tab.
I forked your repl and made these changes and the project passed.

Ok, I will try your method.

Thanks, passed the FCC test

Well, in the previous app test the port value and node_env value are not written in the server.js.

I wonder why for this app, these values have to be written in the server.js file.

I’m not sure I entirely understand your question.
You declare your environment variables in a .env file (or in the case of Replit, in your Secrets tab).

You can then use these variables anywhere you need to (whether in your server file or elsewhere) by referring to them as process.env.VARIABLE or process.env['VARIABLE'].

In this app, they are used in server.js file simply because that’s where the server is setup (which uses process.env.PORT) and the test runner is activated (process.env.NODE_ENV).

Thanks for the information. :smiling_face:

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.