I am using live server and everything works fine if I use one js file. but when I use modules, it gives error in console. due to some reason it doesnt access other javascript file. I am using script properly and it works, and when using module, i define type="module" and its defer also but wont work.
GET http://127.0.0.1:8080/dusra net::ERR_ABORTED 404 (Not Found)
thats the error in console, and 'dusra' is module
I tried live server extention, live server node version. everything, but it just doesnt work with modeuls only, normally live reload works fine.
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
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.)
My live server on visual studio keeps opening an old html file when i try to open my current one. Ive tried reinstalling the extension but its the same problem. Can anyone help please
i cannot have two project folders with an html file running through the live server. Only one html file can be streamed at one time other wise when trying to stream the second, it will stream the first (Like the issue i was having)
I was having the same problem but later on I find out that, I renamed my project folder while my server was still loading the same project but with the previous folder name so I changed the link to my new folder folder name and it worked for me.
I have live server will simply not work if there was an error in JavaScript file.
Even if you do an alert in the beginning of JavaScript file (for test purposes) but at the end of the file re-define a variable which was already defined before, this error will render liver server not working.
The html page will not respond as well.
Solution is to go to developer tools (F12), see the errors on console, fix them and save and the live server would be back in action! At least that was the case with me.
I had the same issue, sometimes it was an error on the console, or keep showing an old HTML, tried everything, deleting cookies, reinstalling everything and nothing worked,
Eventually, it worked with a hard refresh, what it really worked was to
Go to ---> vs code settings ----> extensions ---> live server config set as chrome private. So far no more errors!
The liveserver extension serves static pages like html files and it does not load javascript or typescript files. You need to setup a server yourself for example in react you use webpack to configure your local server and your app runs on a localhost:port. In a nutshell, you need to write a script for node to run your js files. And you won't need liveserver after that.
So everytime I run a test with testcafe, in the URL I tend to get something like http://10.0.75.1:11111/randomCharacters/ThenActualURLHere
is there a way where it just goes to the actual URL I want it to navigate to without the localhost at the start of the URL?
As I've got an issue, the screen I'm attempting to get to is an iFrame with an angular app within the iFrame, however whenever I navigate to the screen, the iFrame is not loading and I get a js error within the console tab of dev tools stating: "failed to load module script the server responded with a non-javascript mime type of text/html. Strict MIME type checking is enforced for module scripts per HTML spec"
However when I'm manually navigating to the screen (without the localhost in the URL) the iFrame loads fine without any js errors.
Thanks
No, it's not possible since TestCafe uses a URL-rewriting proxy which allows it to work without the WebDriver. It looks like you found an error. If you can create an example that can be run locally, please create an issue in the TestCafe repository - https://github.com/DevExpress/testcafe/issues/new?template=bug-report.md.
I'm using w3schools to try to understand how simple AJAX requests work and I came across this exercise page:
http://www.w3schools.com/jquery/tryit.asp?filename=tryjquery_ajax_load
I thought it was a simple example of an ajax request, so I copied and pasted the code into a plain ajax.htm file and copied and pasted the txt file it refers to:
http://www.w3schools.com/jquery/demo_test.txt
...and saved it as demo_test.txt file it refers to and saved them both in the same folder. (Keep in mind, I have an Apache server that processes PHP locally with no problem, so I would think a simple request like this would work on my local machine).
However when I click the button locally I get nothing. Then, when I upload the files to a different server (a "web host") suddenly it works.
So, this works on a webhost and it works at w3schools but it doesn't work locally on my machine in my root folder (where php works without a problem).
I would prefer to not have to upload my code before being able to test whether it works and would rather be able to process everything locally, like I do with PHP. Is it possible to do this locally or can I only make these requests remotely from my web host?
Why is my machine not processing this code? Any help would be appreciated. Thanks.
There are a lot of reasons you might not be able to load the file locally, but most will have to do with how you're serving the files. If you're using file:// you're going to run into problems; you said you have an Apache server, but didn't mention whether you were actually serving this site from it.
Have you checked to make sure that the route you're loading via your AJAX call is actually loading properly? E.g. if the ajax file is at your web root (http://local.site/ajax.html) and so is your txt file (http://local.site/demo_test.txt).
In this situation you can also always check your browser's Javascript console to see if you get any errors or if the files are actually loaded correctly. Depending on how you're serving and accessing the various files, you might be getting CORS errors as well.
The simplest solution is to make sure you're running on a local webserver (your Apache) instead of directly viewing files.