I've a strange issue with an Angular frontend that has been running fine for the last months and all of a sudden the page doesn't load anymore (just white).
In the browser console I see the message
Uncaught SyntaxError: Unexpected token '<' (at runtime.ec2944dd8b20ec099bf3.js:1:1)
Unfortunately I'm not really a web dev and just have limited experience with Angular (rather using React if any). From what I read, this runtime.js is a utility file built by webpack. The whole page runs in a docker container on the server, I tried rebuilding it but issue remains. I see it on every computer in the network and with every browser, so it doesn't seem to be a caching problem.
When I run the Angular project on my local machine with ng serve everything works fine, so the application code itself seems to be okay as well.
Is anyone aware of something that has changed recently that could cause such an issue (altough it would have to be the browser...) or could give me a hint in what direction I should dig?
Presumably the frontend is trying to fetch data from an endpoint where a json-response is expected. If the endpoint is not accessible for some reason the server then returns a normal html-formatted response, which starts with a ' tag. This '<'-character is not valid json or js and it causes the unexpected token exception.
Maybe on localhost it works fine, because locally you have the necessary permissions to access the endpoint, while on production environment these permissions are lacking?
Related
I got an Angular app that calls a window.open that works for with ng serve with http://localhost:4200/newWindow
I can copy and paste this on my ng serve and chrome. it works locally
When the code is deployed to a webserver I get "status":404 "error":"Not Found"
window.open('https://myWebserver.com/newWindow', "_blank");
window.open('/newWindow', "_blank");
Not sure how I can debug or step into the code on the web server.
When I copy and paste the url on chrome ,https://myWebserver.com/newWindow
I get the 404 error but on my local with http://localhost:4200/newWindow, this works.
I tried using the '#' in the url with the following
https://myWebserver.com/#/newWindow
but no luck
Thanks in advance
Angular uses the history API to update the URLs.
The History API is designed to let a developer say: I have modified the document using JavaScript, it is now in the same state as you would get if you just loaded the HTML document from this URL.
Unfortunately, Angular doesn't do much to make that statement true outside of the development server (as you've observed).
The usual ways to solve this problem are with Server-Side Rendering or with Static Site Generation.
A hacky approach is to deliver the same HTML document for all unknown URLs and depend on client-side code to load all the page content for it. (This is bad food for search engines, breaks your ability use to Status 404 when a URL really isn't found, and for situations where the JS fails to load or run for any reason.) How you go about that depends on your server, this page has an example for Apache HTTP.
You need to serve index.html in case of 404 in that domain, this depend on what web-server you're using. Firebase deployments have an option for SPA. while Apache and Nginx requires you to edit the configurations
See Angular SPA returns 404 on Google PageSpeed Insights for Apache
The reason it works in development that ng serve is already handling this
JSP page is not loading after login. same set up is working on Quality system but trying to clone on another system its not working.. guessing the images files path are not reachable in custom project. getting 404 error.. using web sphere server & jdk 1.8
From just your original description it is hard to say what might cause the error, but then if you have reason to believe an image path isn't reachable can you test that theory by logging into the system and seeing if you can access the directory in question. Generally, whether an error in JSP is caused by a compile error or a runtime error, there should be a message or exception in the server log showing more information what went wrong.
Use Vscode for the first time. Use ctrl + f5 to run code. It opens up a chrome window and get hit with a
This site can’t be reachedlocalhost refused to connect.
Try:
Checking the connection
Checking the proxy and the firewall
ERR_CONNECTION_REFUSED
What to do?
You're probably not running a server correctly. But if you are, that probably means you have a problem in your configuration.
If you just want to run a document that is located on your computer, Chrome will run it just fine if you put the file path in your address bar.
(I had a problem just like this when I was just getting started with HTML, CSS, JS. It is also important to note, if you are also just starting out, that the file path will need to point to an HTML document, not a JS. JavaScript normally cannot be rendered on its own.)
I am working on a project with asp.net core 2.2 and react.
Recently I sent a new version to my client, but I got the feedback that the browser window is blank always. I told my client to check the browser console for any fault messages.The browser was showing the following message:
Uncaught SyntaxError: Unexpected token <
I was not able to reproduce this message, so I ask my client to sent back the project which is causing the problems to me. With the project of my client I was able to reproduce the fault. Furthermore I found all JavaScript file extensions are renamed from *.js to *.j_
After renaming the extension back to *.js the fault message is gone, and everything is working as expected.
What could be the reason for remaining the file extension of all JavaScript files? Could it be done by a browser possibly?
Thank you.
The problem was the mail server. Because of security reasons the mail server renamed the JavaScript files contained in the zip-file of the project to *.j_
As weird as this may sound, my website is stored on my localhost and it's taking forever to load. Actually, it never finishes. My website is using Bootstrap 3 for the front-end and the back-end is written in PHP.
This never happened before and I'm unable to find the roots of this problem, but the way my website starting behaving this morning really caught me in surprise. I use some external libraries to power up my website, such as the Javascript libraries to have HTML5 run on IE, Facebook/Twitter/Google+ like buttons and nothing else that may depend on something from the outside.
I've opened up the console in Google Chrome and saw this:
Uncaught SyntaxError: Unexpected token < www.sourcecrab.com/:1
So this is basically failing to load I suspect, causing all this havoc in my website, which is still attempting to load up while I'm trying to post this question.
I've tried searching around for this error, but got nothing returned. Any information to help me find and kill this problem would be appreciated.
I'm using XAMPP on Windows 8.1 to run my local websites.