HTTP Request gives 302 Redirect

epiz_28063674

website : michaelsbookcorner.com

302 Redirect as determined from Chrome Developer Tools

Cross-Origin Read Blocking (CORB) blocked cross-origin response https://infinityfree.net/errors/404/ with MIME type text/html. See Chrome Platform Status for more details.


What am I trying to do?
I would like to keep a .csv data file with my website which I will update periodically with new blog posts containing Titles, publication dates, URLs, thumb image Urls etc.

I would like my page /with JavaScript fetch to access this data to pull relevant information such information for the latest 5 posts to be displayed in that page.

I’m a bit new to this HTTP request stuff and understand the security issues somewhat. However, there must be a way for me to access files stored on the server where my website resides, with the proper access/ passwords/ tokens, whatever.

How do I set this up now and in the future to take advantage of HTTP requests for accessing centralized data files such as .csv, text, etc, and read their data?
I have included my attempt here below – crude as it is. I believe I had it working well enough locally(and without local server) but now on the website server there are problems.


async function blogData () {
var opts = {
mode:‘no-cors’,
credentials: ‘same-origin’

	}

	const response = await fetch("https://michaelsbookcorner.com/HTML-blog/2021-blog-record.csv", opts);
	const data = await response.text();
	console.log("ID","PAGECREATED","UPLOAD","DATE","TITLE","TOPIC","KEYWORDS","URL","FILENAME","ABSTRACT");
	const blogPostArray = [];	
	const table = data.split('\n').slice(1);
	table.forEach(row => {
		console.log(row);
		const columns = row.split(',');
		
		const id = row[0];
		const pageCreated = row[1];
		const upload = row[2];
		const date = row[3];
		const title = row[4];
		const author = row[5];
		const topic = row[6];
		const keyWord1 = row[7];
		const keyWord2 = row[8];
		const keyWord3 = row[9];
		const keyWord4 = row[10];
		const keyWord5 = row[11];
		const keywords = [keyWord1,keyWord2,keyWord3,keyWord4,keyWord5];
		const postURL = row[12];
		const fileName = row[13];
		const imageURL = row[14];
		const abstract = row[15];
		console.log(id, pageCreated, upload, date, title, author, topic, keywords, postURL, fileName, imageURL, postAbstract);
	});
}

As you saw, the URL you’re trying to access is redirecting to our 404 error page. That means the URL could not be found.

Is your local development on Windows or MacOS? Then please note that our servers, like almost all servers, run on Linux, which has case sensitive files and directories, which Windows and MacOS do not. So if you have a file Test.PHP, then calling the URL test.php works on Windows but returns a 404 Not Found error on Linux.

1 Like

Thank you for getting back to me so soon.
I am not sure that I follow. The csv file I wish to access is clearly there in the folder https://michaelsbookcorner.com/HTML-blog/2021-blog-record.csv, so I do not know how it is not being found. Surely I do not understand how this is supposed to work. Does Infinityfree allow the storage of data that can be accessed via HTTP request? This is all new to me.

I have a screenshot of the file shown in its proper place within File Manager. I do not get why there would be a 404 error unless only .html/.css/.js files are allowed. I believe I can place files here for download, so why not data files for access via the client?

Yes, as long as the agent is a browser that’s able to run JavaScript and store Cookies.


No, there’s only one (technically more) file extension restriction, .exe.

1 Like

That is good to hear! I have no intention of doing any file sharing or anything to to do with .exe files. My intention is as stated in the original description. I would like to have a .csv file at the ready with data on my blog posts so I can have javascript determine how to display that information on my web pages such as the latest posts and what is in the archive. The .csv contains a simple table with publication dates, author, title, abstract, and urls for a thumbnail and the article page itself.

My problem is that I do not have a sufficient understanding of how to set that up such that I can fetch the file so I can scan the data for that purpose. I keep getting hung up on CORS or CORB, or 404 errors. It is a problem of me not understanding the mechanics of how to do that it seems. Are there some good examples of code doing this? Are there issues specific to Infinityfree I need to be aware of? If there are HTTP header setings I need to fix, I also need direction on how to do that at Infinityfree. I am having considerable trouble in locating such code to educate myself. I am very glad to hear that what I am attempting is not a restriction of the free accounts.

I think you would be better suited using MySQL for this.

I looked in this directory:

image

And there are a few sub folders there, but no files directly in that folder. So there is no file 2021-blog-record.csv there.

If I look inside the folder blogFiles, the file is there. So if you try to access https://michaelsbookcorner.com/HTML-blog/blogFiles/2021-blog-record.csv , you’ll see the file being downloaded in your browser.

2 Likes

The thought had occurred to me. I am also new to mySQL but have had it working in a limited capacity. Likely that will be more flexible for what I wish to do. Is it necessary to use only .php pages for that? or just snippets of .php code?

Ok, I am back! Sort of…
I have a new database on Infinityfree but now I cannot seem to make a connection to the table I created there. It has to be simple which is why I cannot figure it out.

I created a database and one table called blogPosts.
Using an example skeleton connect file I found, I inserted my information for (Host_Name, User_Name, Password, Database_name) into the connect section, then the name of my table below where the command is to print out the contents. Where the YES comes from in the error message, I do not know.

Evidently I am not connecting at all as this is the error I get…


Warning : mysqli_connect(): (HY000/1045): Access denied for user ‘epiz_28063674’@‘192.168.0.50’ (using password: YES) in /home/vol11_4/epizy.com/epiz_28063674/michaelsbookcorner.com/htdocs/HTML-blog/blogFiles/blogData.php on line 3
Error connecting to MySQL server.


The code for the page I put up on Infinityfree to access the database and table is as follows for file blogData.php. The InfinityFree password is disguised, of course.

( line 1)<?php ( line 2)//Step1 ( line 3) $db = mysqli_connect('sql113.epizy.com','epiz_28063674','1aZZZZZV','epiz_28063674_cornerBlog') ( line 4) or die('Error connecting to MySQL server.'); ( line 5)?>

PHP connect to MySQL

<?php //Step2 $query = "SELECT * FROM blogPosts"; mysqli_query($db, $query) or die('Error querying database.'); ?>

Is there something really obvious that I am doing wrong?

Is the password “YES”? I assume not. The password is the same password for your FTP account and cPanel.

Exactly. I used the same password listed there under MySQL information alongside the FTP login server and password info at the bottom of the page where one accesses File Manager or Control Panel.

OK! I followed the same example but took it a bit further…
However, I put the data tables on another location this time, namely remotemysql.com and using the free database, user name, password yada yada yada. Things seem to have progressed there to a greater degree.

The page is
https://michaelsbookcorner.com/HTML-blog/blogFiles/blogData-R.php

The code is essentially the same, but nothing was blocking a connection this time.

Here is the code for the page link above…only the password is disguised. The order is the same, namely –
Server, UserName, Password, DatabaseName which should not be different for Infiityfree, correct? Remotemysql is not recommended for production which is why I am trying to get the Infinityfree database working.

------------------------------- blogData-R.php ---------------

<?php
//Step1
 $db = mysqli_connect('remotemysql.com','O2YC3uWjnV','byXXXUs40I','O2YC3uWjnV')
 or die('Error connecting to MySQL server.');
?>

<html>
 <head>
 </head>
 <body>
 <h1>Corner Blog Listing</h1>
 
<?php
//Step2

$query = "SELECT * FROM blogPosts";
mysqli_query($db, $query) or die('Error querying database.');
	 
$result = mysqli_query($db, $query);
$row = mysqli_fetch_array($result);

while ($row = mysqli_fetch_array($result)) {
 echo $row['title'] . '<br />' . $row['dateFancy'] . ' by  ' . $row['author'] . '<br />Subject: ' . $row['topic'] . '<br />Abstract:  ' . $row['abstract'] .'<br /><br />';
}	 
	 
?>	
	 

	 
</body>
</html>

I checked your configuration and found the issue.

The issue is that in your code, your password starts with a 1, but the real password starts with an l. It was hard to spot for me too. But next time, you may want to copy-paste the password instead of typing it by hand.

3 Likes

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