'null' has been blocked by CORS policy, could somebody help me find the problem - cross-domain

I'm getting this error:
Access to XMLHttpRequest at 'file:///Users/jonathanguerrero/Documents/GitHub/scoreboard_proj/app.js' from origin 'null' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, chrome-untrusted, https.
This is my code:
<html>
<head>
<meta charset="utf-8">
<title>Scoreboard</title>
<link rel="stylesheet" href="./app.css" />
</head>
<body>
<div id="root"></div>
<script crossorigin src="https://unpkg.com/react#16/umd/react.development.js"></script>
<script crossorigin src="https://unpkg.com/react-dom#16/umd/react-dom.development.js"></script>
<script src="https://unpkg.com/babel-standalone#6/babel.min.js"></script>
<script type="text/babel" src="./app.js"></script>
</body>
</html>```

install Live server extention on your editor then run it. and it will work

Related

Vue code doesn't show up with Webpack Bundle Tracker

I run both the vue and the django.
I have installed webpack_loader and have it in installed apps.
I have the WEBPACK_LOADER in settings.py
WEBPACK_LOADER = {
'DEFAULT': {
'BUNDLE_DIR_NAME': 'dist/',
'STATS_FILE': os.path.join(BASE_DIR, 'frontend', 'webpack-stats.json'),
}
}
frontend is the name when creating vue.
Here is some more details KeyError at / 'assets' and ModuleNotFoundError: No module named 'webpack_loader'
My page source from http://localhost:8000/ looks like this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>QuestionTime</title>
</head>
<body>
<h1>Vue JS</h1>
<noscript>
<strong>We're sorry but <%= htmlWebpackPlugin.options.title %> doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<script type="text/javascript" src="http://0.0.0.0:8080/bundle.js" ></script>
</body>
</html>
My page source from http://localhost:8080/ looks like this
<!DOCTYPE html>
<html lang="">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0">
<link rel="icon" href="/favicon.ico">
<title>hello-vue</title>
<link href="/js/about.js" rel="prefetch"><link href="/js/app.js" rel="preload" as="script"><link href="/js/chunk-vendors.js" rel="preload" as="script"></head>
<body>
<noscript>
<strong>We're sorry but hello-vue doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
<!-- built files will be auto injected -->
<script type="text/javascript" src="/js/chunk-vendors.js"></script><script type="text/javascript" src="/js/app.js"></script></body>
</html>
When I use (django-webpack-loader 1.0.0), I get KeyError at /
When I use (django_webpack-loader 0.7.0), I get no errors, but the vue code doesn't show up (But I see it at localhost:8080).
Just started to work Today, I didn't do anything, and it started to work. I tried 2 times to make a new project with the same code, downloaded all the stuff again.
Didn't work. But then my vue code suddenly stopped working. I turned the server on and off. And then I saw that my vue code had been updated.
I then went to localhost:8000 to see if it worked, and it did.
I believe that God fixed it. Not sure what else it would be.
EDIT: 8 July 2022
I happened to get the error: TypeError: expected string or bytes-like object.
It was point to {% render_bundle 'chunk-vendors' %}
The problem was that I had upgraded the django-webpack-loader to the latest version, the error went away when I use this version django-webpack-loader==0.6.0.
I tried django-webpack-loader==0.7.0 and it works as well.
The version of webpack-bundle-tracker I'm using is 0.4.3

Cannot render css for cesium viewer from local server

I am trying to render the basic cesium viewer from a local development server using node.js with express (cesium 1.57 downloaded via npm). The page loads correctly when the CSS is loaded from cesium's servers, but not when I try to load it locally from my node_modules folder. I'd like to have the files server side so I can eventually change the display and certain sandbox settings for the infoboxes to suit the app I'd like to build.
This works:
index.html:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>mapsTest</title>
<script src="/scripts/Cesium.js"></script>
<link href="https://cesiumjs.org/releases/1.57/Build/Cesium/Widgets/widgets.css" rel="stylesheet" />
<!-- <link type=text/css href='/styles/widgets.css'></link> -->
</head>
<body>
<div id="cesiumContainer" style="width: 100%; height:100%"></div>
<script>
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhYzhjNjk0My04MzNjLTQyZTItOWRkOS1lZmQxYjE2YzM4NDYiLCJpZCI6MTAyMTYsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1NTU5NjMzNjB9.DSk7rCttQeOvYyCnuesEtoiA8OUSGwitJaiBUUeqlxw';
var viewer = new Cesium.Viewer('cesiumContainer');
</script>
</body>
</html>
While this doesn't work:
index.html:
<!DOCTYPE html>
<html lang="en" dir="ltr">
<head>
<meta charset="utf-8">
<title>mapsTest</title>
<script src="/scripts/Cesium.js"></script>
<!-- <link href="https://cesiumjs.org/releases/1.57/Build/Cesium/Widgets/widgets.css" rel="stylesheet" /> -->
<link type=text/css href='/styles/widgets.css'></link>
</head>
<body>
<div id="cesiumContainer" style="width: 100%; height:100%"></div>
<script>
Cesium.Ion.defaultAccessToken = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJqdGkiOiJhYzhjNjk0My04MzNjLTQyZTItOWRkOS1lZmQxYjE2YzM4NDYiLCJpZCI6MTAyMTYsInNjb3BlcyI6WyJhc3IiLCJnYyJdLCJpYXQiOjE1NTU5NjMzNjB9.DSk7rCttQeOvYyCnuesEtoiA8OUSGwitJaiBUUeqlxw';
var viewer = new Cesium.Viewer('cesiumContainer');
</script>
</body>
</html>
app.js: setting up the routes for getting the local css file
app.use('/styles', express.static(__dirname + '/node_modules/cesium/Build/CesiumUnminified/Widgets'));
app.get('/styles/widgets.css', function(req, res) {
res.sendFile(__dirname + '/node_modules/cesium/Build/CesiumUnminified/Widgets/widgets.css');
});
I've tried copy and pasting the code that is pulled from the cesium css link into my local copy of widgets.css, though it still doesn't work, so I am wondering whether this has something to do with how node/express loads css files? There are no errors in the firefox or chrome consoles when I load the page.
I think you might just be missing rel="stylesheet" in the link there.
Also type="text/css" is missing the double-quotes.

Angular production build with index.jsp instead of index.html

I want want to create an index.jsp file instead of index.html while doing production build. This weird requirement is for capturing the header part which we will getting from other Oracle Authentication Manager so I want load my appliation from index.jsp. My index.jsp should look something like this
<%# page language="java" import="java.util.*" session="true" %>
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>CardEncryption</title>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">
<base href="/">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="icon" type="image/x-icon" href="favicon.ico">
<link rel="stylesheet" href="styles.3ff695c00d717f2d2a11.css"></head>
<body>
<app-root></app-root>
<script type="text/javascript" src="runtime.06daa30a2963fa413676.js"></script><script type="text/javascript" src="polyfills.9a8743e2009b1e7b1fbd.js"></script><script type="text/javascript" src="main.dcf4ad6dff6130812df3.js"></script></body>
</html>
Any suggestion to do this.
I suppose you only want the index.jsp when doing the production build. The development process should still use index.html
In that case you should
Create a index.jsp file in the same directory as your index.html file (so you have both).
Update your angular.json file's production configuration by adding an index property to your production configuration like this:
That will make sure that it uses index.jsp when you build with --prod, but still uses index.html for development.

Angular2 Visual Studio 2017 MVC: Uncaught TypeError: System.config is not a function

I am building Angular2 web application through Visual Studio 2017 ASP.NET MVC
All the basic configuration I did.
But when I am trying to build app then it is throwing an error.
Error:
I am surprised some time application run successfully and sometimes it throws this error.
Following this link to do quick setup
package.json, tsconfig.json and systemjs.config.js
copied from quickstart
_Layout.cshtml
<!DOCTYPE html>
<html>
<head>
<script src="/node_modules/core-js/client/shim.min.js"></script>
<script src="/node_modules/zone.js/dist/zone.js"></script>
<script src="/node_modules/systemjs/dist/system.src.js"></script>
<script src="/system.config.js"></script>
<script>
System.import('app').catch(function (err) { console.error(err); });
</script>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>#ViewBag.Title - My ASP.NET Application</title>
#Styles.Render("~/Content/css")
#Scripts.Render("~/bundles/modernizr")
</head>
<body>
<div class="container body-content">
#RenderBody()
<hr />
<footer>
<p>© #DateTime.Now.Year - My ASP.NET Application</p>
</footer>
</div>
#Scripts.Render("~/bundles/jquery")
#Scripts.Render("~/bundles/bootstrap")
#RenderSection("scripts", required: false)
</body>
</html>
Index.cshtml
#{
ViewBag.Title = "Home Page";
}
<app-root>Loading...</app-root>
You need to resolve the path to your script with Url.Content():
<script src="#Url.Content("~/node_modules/core-js/client/shim.min.js")"></script>
<script src="#Url.Content("~/node_modules/zone.js/dist/zone.js")"></script>
<script src="#Url.Content("~/node_modules/systemjs/dist/system.src.js")"></script>
<script src="#Url.Content("~/system.config.js")"></script>
This way you ensure it is always resolving to the root of your applications path and not some fubfolder if your Route changes to /controller/action/something.

Fitnesse on Linux with Jenkins

I've been trying to setup Fitnesse on a centos7 machine with Jenkins but ran into a few problems.
I have Jenkins using the Fitnesse plugin and starting an instance of Fitnesse which it does fine but then it cant seem to connect to the started Fitnesse server with an error message "Fitnesse server NOT started in 30000ms on URL: "
At First I thought it was a problem with localhost not being able to connect to it but I am able to connect on the centos machine using firefox and localhost: while Jenkins is also trying (and failing) to connect to it. So I used telnet to ping it and it produces the following:
Trying ::1...
Connected to localhost.
Escape character is '^]'.
HTTP/1.1 408 Request Time-out
Content-Length: 2131
Connection: close
Server: FitNesse-v20150424
Content-Type: text/html; charset=UTF-8
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Error Occurred</title>
<!--[if lt IE 9]>
<script>
document.createElement('header');
document.createElement('nav');
document.createElement('section');
document.createElement('article');
document.createElement('footer');
</script>
<![endif]-->
<link rel="shortcut icon" type="image/png" href="/files/fitnesse/images/favicon.png" />
<link rel="stylesheet" type="text/css" href="/files/fitnesse/css/fitnesse_wiki.css" />
<link rel="stylesheet" type="text/css" href="/files/fitnesse/css/fitnesse_pages.css" />
<link rel="stylesheet" type="text/css" href="/files/fitnesse/wysiwyg/wysiwyg.css" media="screen"/>
<link rel="stylesheet" type="text/css" href="/files/fitnesse/bootstrap/css/fitnesse-bootstrap.css">
<link rel="stylesheet" type="text/css" href="/files/fitnesse/question.mark/question.mark.css" />
<script src="/files/fitnesse/javascript/jquery-1.7.2.min.js" type="text/javascript"></script>
<script src="/files/fitnesse/javascript/fitnesse.js" type="text/javascript"></script>
<script src="/files/fitnesse/bootstrap/js/bootstrap.js" type="text/javascript"></script>
<script src="/files/fitnesse/bootstrap/js/respond.js" type="text/javascript"></script>
</head>
<body class="error">
<nav class="navbar-fixed-top " role="navigation">
<div class="navbar navbar-default">
<!-- Brand and toggle get grouped for better mobile display -->
<div class="navbar-header">
<a class="navbar-brand" href="/FrontPage"><span>FitNesse</span></a>
</div>
</div>
<ol class="page-actions btn-group">
<li class="expandall btn btn-xs">Expand All</li>
<li class="collapseall btn btn-xs">Collapse All</li>
</ol>
<ol class="breadcrumb">
<li>Error Occurred</li>
</ol>
</nav>
<header>
</header>
<article>
<center>The client request has been unproductive for too long. It has timed out and will now longer be processed.</center>
</article>
</body>
</html>
Connection closed by foreign host
So it looks like it actually IS conncting to Fitnesse, but Fitnesse isn't responding properly or something? Does anyone have any insight on the problem or possible solutions?
Are you setting up this pipeline job on a node?
It seems the Fitnesse plugin connects to Fitnesse from the master always. Hence, localhost will not answer, if fitnesse was started on a node.
For now, you will have to run fitnesse jobs only on the master.

Resources