添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hey Guys;
Strange- it was working, then I broke out my script.js into routes.js and auth.js and now I get this error:

Repl.it: Updating package configuration
--> npm install bccryptjs bcryptjs
npm ERR! code E404
npm ERR! 404 Not Found - GET https://registry.npmjs.org/bccryptjs - Not found
npm ERR! 404 
npm ERR! 404  'bccryptjs@latest' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404 
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2020-08-30T15_53_39_053Z-debug.log
exit status 1
Repl.it: Package operation failed.

Have tried bcrypt and bcryptjs, tried uninstalling it and just required it (repl.it says it will auto instal it, but that didn’t work either).

I see some talk of bcrypt being depreciated but I don’t see why it works when all in server.js and not when seperating routes out.

My code is good, it’s just this install that’s hanging it up.

Anyone else see this problem?

Thanks

Sorry, mistake on forum, it is spelled correctly in my package and code for auth.js …but noticed spelled wrong on my routes.js!

Thanks guys!!!

So that worked and now it’s running well again :slight_smile:
but when I submit to pass test, tests fail. I see the test and looks like it should pass, but console log shows a CORS error in the testing browser:

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://boilerplate-advancednode.pauloconnell.repl.co/_api/server.js. (Reason: CORS header “Access-Control-Allow-Origin” does not match “https://boilerplate-advancednode.pauloconnell.repl.co/_api/server.js”).

I tried adding: cookie: {secure: false}
to the app.use(session, but no dice…

Any ideas how to get around that CORS error upon submit to FCC?

Thanks

That worked!
I console logged out the ‘origin’ and saw it was www.freecodecamp.org, so switched res.setHeader from https://boilerplate-advancednode.pauloconnell.repl.co
www.freecodecamp.org
And it passed :slight_smile:

app.use(function (req, res, next) {
      const origin = req.get('origin');
      console.log("CORS debug- origin is: "+origin);
      if (allowedOriginsMatcher.test(origin)) {
            res.setHeader('Access-Control-Allow-Origin', 'https://www.freecodecamp.org');
      res.setHeader('Access-Control-Allow-Credentials', true);
      next();