How to use glitch with FCC?

Can you share the codepen link?

i have write code in glitch.com not codepen

here’s screen

i use github share the code still not found : https://raw.githubusercontent.com/Restry/glitch/glitch/package.json

this’s glitch picture

You may try with: https://glitch.com/edit/#!/stump-mailbox?path=package.json

still not working .

thanks sorinr
i have resolve this issue

the key its server.js

fcc fetch code with _api/filename when check solution . so the glitch project must have cros settings

 /******************************************************
 * PLEASE DO NOT EDIT THIS FILE
 * the verification process may break
 * ***************************************************/

'use strict';

var fs = require('fs');
var express = require('express');
var app = express();

if (!process.env.DISABLE_XORIGIN) {
  app.use(function(req, res, next) {
    var allowedOrigins = ['https://narrow-plane.gomix.me', 'https://www.freecodecamp.com'];
    var origin = req.headers.origin || '*';
    if(!process.env.XORIG_RESTRICT || allowedOrigins.indexOf(origin) > -1){
         console.log(origin);
         res.setHeader('Access-Control-Allow-Origin', origin);
         res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
    }
    next();
  });
}

app.use('/public', express.static(process.cwd() + '/public'));

app.route('/_api/package.json')
  .get(function(req, res, next) {
    console.log('requested');
    fs.readFile(__dirname + '/package.json', function(err, data) {
      if(err) return next(err);
      res.type('txt').send(data.toString());
    });
  });
  
app.route('/')
    .get(function(req, res) {
		  res.sendFile(process.cwd() + '/views/index.html');
    })

// Respond not found to all the wrong routes
app.use(function(req, res, next){
  res.status(404);
  res.type('txt').send('Not found');
});

// Error Middleware
app.use(function(err, req, res, next) {
  if(err) {
    res.status(err.status || 500)
      .type('txt')
      .send(err.message || 'SERVER ERROR');
  }  
})

app.listen(process.env.PORT, function () {
  console.log('Node.js listening ...');
});


8 Likes

Having the same issue with both glitch and github, thank your for the solution

you are welcome :slight_smile:

can u post an example link for github please? i still don’t get it

you can find the code from here : Flicker Ostrich

this’s my glitch site

1 Like

this’s github sample code

Just put link of your app (you can get from share button on upper left side of Glitch page) to challenge “solution” field.

Hello. Thank you, i tried that but i get a timeout erro

Try copying server.js from github into a server.js in glitch

Hello @JohnPA, The error remains.
https://freecodecamp-boilerplate-infosec-11.glitch.me/boilerplate-infosec/package.json

I still can’t get this to work either. FCC, can you please help with what is going on with glitch?

how can i help u ? ???

Sorry, I fixed the issue. For those that can’t get it working:
Clone the fcc github from the link provided.
Create a new project on Glitch and select the option to clone from repository.
Then copy the link to the fcc GitHub.
Next Drag and drop the files from your cloned copy into glitch.(you can’t drag folders, so open the views folder on your cloned copy and drag and drop the index.html file.)
Next go to server.js file on glitch that you added earlier and change the file path of index.html by removing the views directory.
It should be:

‘/index.html’

1 Like

Sorry, I still can’t get this to work… There must be something broken:

I tried this with my new glitch repo at:

This is what I get all the time…

Drives me crazy, since I have no idea what I might be doing wrong.

Also: it took me a while to figure out, what exactly to put in the submission field… A simple explanation with example would help…

Thank you!

In your glitch project, Click the show Dropdown

and choose open in a new window option
when the browser loads the html page of your project,
copy and paste this url in the Solution textbox.

7 Likes