Apache2 not serving javascript/css when using CGI.pm perl script to render web page

Tags: , , , ,



I am working on a college assignment which requires me to stick with perl and cgi.pm to render webpages.

With my current implementation I have included a javascript cdn for a javascript library (p5js) and another script tag that points to a js file present in the cgi-bin folder.

All the html content seems to be working fine, but I keep getting a 404 error saying that the files can’t be found, despite it being there

The webpage works fine when executed as a regular html page.

If the cgi-bin directory is not the expected location, please let me know where to place the js files as well as how to point to them using a the script tag

Answer

From the browser view the js files are static content so apache try to get it from the DocumentRoot. Put it there or better make a directory DocumentRoot/js an locate all js files there. The path part of the URL looks then like /js/p5.js



Source: stackoverflow