bundle.js not loaded successfully in static html files but refer to - html

I have a static index.html in wwwroot of an asp.net core web project which useStaticFiles:
<html>
...
<body>
...
<script src="~/scripts/bundle.js"></script>
</body>
</html>
After web application published. the bundle.js could not load successfully, after F12 in Chrome and found browser trying to load js by url:
https://127.0.0.1:5001/~/scripts/bundle.js
Please help a clue. thanks!
By the way, the web application run fluently without such errors locally.

It's actually an Nginx configuration issue. https://www.***.com/subpath1/test.html.
nginx proxied subpath1 to local port 5588 where test.html hosted in.
In test.html <script src="bundle.js"> didn't refer to
https://www.***.com/subpath1/bundle.js as expected but https://www.***.com/bundle.js
So update test.html src attribute src="subpath1/bundle.js" solved the problem.
Thanks all~

Related

blockquote does not return anything

This sample works in codepen, but not work in my html file?
why is this happening?
i already tried to add https:// to href, but still not working
<script async src="//s.imgur.com/min/embed.js" charset="utf-8"></script>
a
<blockquote class="imgur-embed-pub" lang="en" data-id="KUteCdn">
View post on imgur.com
</blockquote>
My guess is that this is a CORS related issue, verify this by checking your js console. To rectify this, you can run a simple HTTP server and serve the html file from there.
on Mac OS you run the following in terminal from your working directory
http-server -p 4090 .
In your web browser, navigate to http://localhost:4090
This will stop you from receiving such an erroe

Html favicon not showing up

My localhost web page hadn't show favicon, and also not found in Network request:
The webpack-dev-server host the web page including index.html, favicon and other files:
The favicon.ico can be accessed from http://localhost:8080/favicon.ico in browser.
It's cache problem. I configured other port in webpack devServer and works.
Thanks #Hardik's
check webpack setting for icon
{
test: /\.(ico)$/,
use: 'file-loader?name=assets/[name].[ext]'
}

html containing iframe won't display in browser

I want to embed a video stream in a html page. I run apache on a raspberry pi. With the standard index.html it works fine. When I change to my custom index.html, it says the page takes too long to load. This occurs when I access from another network (the internet) not the local network.
This is the content of the html page:
<html>
<head>
</head>
<body>
<iframe src=”http://192.168.1.56:8081” height=”480” width=”640”>
</iframe>
</body>
</hmtl>
My research has led me to X-Frame-Options (this is the best reference https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/X-Frame-Options i found).
I have enabled the headers module
a2enmod headers.load
systemctl restart apache2
and added the following line at the end of the apache2.conf file
Header always set X-Frame-Options “ALLOW-FROM http://192.168.1.56:8081”
Could you please help?
Thanks!`

Ajax downloaded Javascript not executing in grails

I have a layout which loads all my common resources used throughout my app but when I load a page via ajax the gsp itself renders and I can see that the ajax call downloads the js file (via firebug) but the actual code does not get executed.
I have tried the following ways to download and execute the js file from the ajax loaded page with no success. Any help will be appreciated.
Approach used
<r:require modules="announcements" />
<r:layoutResources/>
Result: js file downloaded but not executed
Approach used
<g:javascript library="announcements"/>
with and without
<r:layoutResources/>
Result: File not downloaded
Approach:
<script type="text/javascript" src="js/announcements.js"></script>
Result: http code 302 temporary move and attempt to download of js/static/announcements.js
which gives a http code 200 but firebug shows that it is still waiting for the file and thus it's not executed.
layout.gsp:
<html>
<head>
...
<g:if test="${session.isLoggedIn}">
<r:require modules="ui, jqueryDateFormat, loggedin" />
</g:if>
<g:else>
<r:require modules="ui" />
</g:else>
<r:layoutResources/>
<g:layoutHead />
</head>
...
</html>
ajax loaded page
<html>
<head>
<all methods mentioned above>
...
</head>
<body>
...
</body>
</html>
UPDATE: I resolved the issue. Turns out there was a syntax error in my JS file. Firebug did not identify error, it just stopped because the JS crashed. Had to move the library call to my layout to find the error. Fixed the JS and moved added the line back to the gsp and all worked again.
This is the most correct method.
<script type="text/javascript" src="js/announcements.js"></script>
You should check your webserver configuration if 302 produce 200 but file isn't downloaded

Application cache in HTML5 not working:

I'm newbie to HTML 5 Application storage. Im trying a sample to test the offline storage. I have few questions. Please help.
Files used:
index.html
<html manifest="demo.manifest">
<head>
<link rel="stylesheet" href="style.css" type="text/css" />
<script type="text/javascript" src="script.js" ></script>
</head>
<body>
<h1>some text</h1>
<p>Some text.</p>
</body>
</html>
style.css
body{background-color: #333;}
h1{color: #c94054;}
p{color: #fff;}
demo.manifest
CACHE MANIFEST
CACHE:
style.css
index.html
I know that demo.manifest MIME type has to be set to text/cache-manifest and this has to be done in the *.htaccess file. I'm using apache tomcat 6.0 server on a windows environment. I'm not able to find this file inside the server. So, I created one (test.htaccess) in the root directory of my project (which is being developed on eclipse helios) that is, in d:/eclipse-workspace/ProjectName/ and my file looks like below:
test.htaccess
AddType text/cache-manifest .manifest
But application cache does not work when I stop the server and tried to access it as below:
http://localhost:8081/ProjectName/index.html
Please let me know what have I done wrong with this...Also, Is there a way to debug application cache
On a Tomcat server the MIME types are configured via the default web.xml file, conf/web.xml
Towards the end of that file you'll find a bunch of defined MIME types. You have to add
<mime-mapping>
<extension>manifest</extension>
<mime-type>text/cache-manifest</mime-type>
</mime-mapping>
as the equivalent of what you'd put in .htaccess as used by Apache and other servers.
I had the same problem. Everything looked right: paths were correct, the manifest was in my project and I could manually browse to it, MIME type was set. It simply wasn't attempting to get this file from my HTML. The problem was I hadn't included the required line at the beginning of the manifest:
CACHE MANIFEST
Not having this was causing the browser to just silently ignore the manifest tag.