Advanced Node and Express - Set up a Template Engine 提交后无法通过


#1

Tell us what’s happening:

提交代码后无法通过,英文站能通过

Your code so far
https://angry-aunt.glitch.me

'use strict';

const express     = require('express');
const bodyParser  = require('body-parser');
const fccTesting  = require('./freeCodeCamp/fcctesting.js');
const pug         = require('pug');
const app = express();


fccTesting(app); //For FCC testing purposes
app.use('/public', express.static(process.cwd() + '/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

//set up a template engine
app.set('view engine','pug');

app.route('/')
  .get((req, res) => {
    res.render(process.cwd() + '/views/pug/index');
  });

app.listen(process.env.PORT || 3000, () => {
  console.log("Listening on port " + process.env.PORT);
});

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.131 Safari/537.36.

Link to the challenge:
https://learn.freecodecamp.one/javascript-algorithms-and-data-structures/intermediate-algorithm-scripting/seek-and-destroy/


#2

修改freeCodeCamp/fcctesting.js 中的正则表达式
改为
const allowedOriginsMatcher = /^https?:\/\/([\w-]+\.)*freecodecamp.(one|org)/;

这是因为模板是设计为跨域允许通过freecodecamp.org访问,以便于通过测试
从中文版的.one访问,也需要把freecodecamp.one列入跨域许可列表