I want to check the remix logs of my site, Glitch :・゚✧. How can I do so?
You can run the following to see where your project originated from in the logs tab:
console.log(process.env.PROJECT_REMIX_CHAIN)
// ["a0fcd798-9ddf-42e5-8205-17158d4bf5bb","c62efef6-1e75-45cf-b248-afeccdda9477"]
// returns ids
I know this isn’t a great answer, but this is the best way to find out at the moment.
Will that actually show a list of ID’s in a React or Node app? Because I tried to do a quick and dirty version in a regular HTML file with a script and dotenv cdn and it tells me require and process.env are not defined. lol. It needs to be secured anyway…
EDIT: I tried it with import.meta.env.PROJECT_REMIX_CHAIN in a Vite/React project and no dice. Can kinda see why but I thought it might just work…oh well.
Hi, in a Vite/React app if you try importing loadEnv
in vite.config.js
you should hopefully be able to get the remix chain, like this extending the code in the Glitch Hello React app:
import { defineConfig, loadEnv } from "vite";
console.log(process.env.PROJECT_REMIX_CHAIN);
Thanks, I added the loadEnv and I still get process not defined, in the terminal, console, and within the app. Does it have to be connected with an API? Because I have a React Covid tracker, which I’m using an example, and that one has a few working APIs hooked up using Fetch and an .env file. The import.meta stuff is in an X-App-Token header, though. This is the project - https://react-covid-19-tracker.glitch.me.
I’ve had a similar issue with Vite before. Maybe node-fetch would be better for this, within a Node app.
So hopefully this is reproducible lol but I remixed your project, removed the PROJECT_REMIX_CHAIN
var that you have declared in the .env
, refreshed and it seemed to work - maybe having it explicitly declared was overwriting the default one…?
That’s odd because I added that to the .env file later on. Maybe it just needed a refresh?
How did you console.log it? Did you do that in the terminal or in the browser?
EDIT: Maybe there just aren’t any remixes so it doesn’t create a log for me.
Oh cool! It does work for me right in the config file like that. Thanks! I was trying to display the data on a page or by console.logging in the browser. Is that info somehow restricted to being shown in the Glitch logs?
NP! Yep so I think that’s down to how the site is built when it’s Vite/React, like it’s accessible to the build process so you’d need to explicitly pass it to the front-end…?
For Vite apps I know they want every .env to start with VITE_ so that might be why it’s not showing, outside of the logs. With a Node app it shouldn’t matter.
I’m gonna play around with all this more later today. Thanks for all your help and insight!
so what is the easiest way to check my remix logs on https://vhe.glitch.me? (my glitch project)
my app is running on node
Hey, I tried adding some code to your app, let me know if you can see any remix logs after you login. The login didn’t work for me.
EDIT: your project is newly created so you may not have remixes yet. If I do a console.log in the server.js file, it doesn’t show anything but I don’t get an error either. More specifically: I’ve added the dotenv package, and some JS code to the head of your index.html file, plus a div for displaying. If you remix the project or apply it to another Node app, hopefully you will see logs.
Just to clarify, as @RiversideRocks mentioned, the remix chain is the chain of projects leading up to yours vs projects remixed from yours…
That’s useful thanks! I got confused lol.
I got the chain showing in my Glitch logs on this Node app. See the server.js file. But on the front end, I get process not defined, not quite sure why.
would you be able to set it up on my app Glitch :・゚✧, or did you already do that?
I did - see your server.js file. I don’t see anything in your logs though. You have a lot of other code in there, probably why.
i think i tested it on another project, it gave me some unrelated links though. How do I restart my app?
Gave up and am just using the Glitch API at this point. I remembered the remix chains are in there… I haven’t set it up to show properly on a webpage yet but I know how to. I’ve updated my last link (node-basic-auth-remix)
could you try making a small page for remix logs, and make it able to be remixable and usable by changing a link inside of the code? or does it have to be on the project I want to log?
I’m not sure what you mean - you’d be able to remix it no matter what if it’s public. You have to change the domain in the link on line 37 of the server.js file to the site you want to look at to see its remix chain. I have it set to the app I’m currently working on but it could point to someone else’s app.
edit: actually I think I understand - yes, what you’re saying is possible. if there’s an input on the front for someone to enter the site domain name they want.
Your remix log for vhe is right here - https://api.glitch.com/v1/projects/by/domain?domain=vhe
And then to convert those IDs to project names…
https://api.glitch.com/v1/projects/by/id?id=5acf512a-88cf-49e7-96a7-97106fa47ba2
I am hoping I can get this going more easily by fetching right from the API but so far it’s not quite doing what I want. I’m about to pull it all into a regular HTML site though because the API is open anyway.
hey @RiversideRocks - any idea why the second function here might not be working? I’m hoping I can get it to search. https://iodized-mellow-year.glitch.me/
data.domain isn’t defined. The Glitch API puts JSON responses like this (for the domain “test”):
{
"test": {
"private": false,
"id": "5886c2cb-c97d-464c-a825-62bb472e99c0",
"description": "A quaint project that does moral things",
"domain": "test",
"baseId": "b51ca96c-39eb-4c2d-929a-3848920ae2f1",
"gitRepoUrl": null,
and so on..
What you would instead want to do is print data.project.domain. From your code it looks you have the domain set to item, so:
if (item.trim()) {
fetch(`https://api.glitch.com/v1/projects/by/domain?domain=${item}`)
.then(res => res.json())
.then(data => {
console.log(data)
if (data === null) {
resultText.textContent =
'There are no search results. Try again!'
} else {
//data.map(data =>
log.insertAdjacentHTML(
'afterbegin',
`<p>${data.item.domain.remixChain}</p>`
)
}
})
search.value = ''
} else {
resultText.textContent = 'You must search for something.'
}
I tried that, and keep getting undefined. I initially had it set to ‘domain’ and later switched it to ‘item.’
I think it doesn’t like using that /projects/by/domain?domain=something in search. There’s a different (shorter) endpoint for searching built into the API but it throws a database error. I’ve gotten the sense the API is still being worked on?
I added you as a collaborator to the project if you want to poke around in there. You seem to know it well.
This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.