I'm locally developing an Angularjs app. I'm using the same node web server as in the Angularjs tutorial. The link to the code for the web-server on Github.
The problem is that I can't seem to get html5mode to work on the node server. What I understand so far is that i have to add a base href to my app and rewrite the server code. I tried rewriting the node web server code, but I failed and it didn't work. Could someone please help me in what i should exactly change? Or does someone maybe already has a version of the server rewritten?
The link to my app looks like this: http://localhost:8000/app/index.html
Also refreshing the page on a html5 link doesn't work. Like this: http://localhost:8000/schedule.
Thanks
You have to rewrite incoming requests that aren't to your REST endpoints respond with the same response as the request to /app/index.html.
Related
I'm working on a decentralized p2p chat system that runs exclusively in the browser. There literally is no server to speak of. I want to persist message history, and IPFS looks like a good way to do that. However, every tutorial and example I can find requires a node.js server, React or Angular (per this)--none of which will work with what I've built.
I have identified some public IPFS gateways that I could potentially use here. But without a server hosting the IPFS api, and no html/javascript exclusive examples, how can I build this?
One idea I was going to explore was running node with express in the browser, which I've done in the past for other projects not using IPFS. But I would like to avoid that if possible.
Is using IPFS without a server hosting the page impossible at this time? What am I missing/overlooking?
I found my own answer and was able to successfully upload and retrieve a file from IPFS using js-ipfs.
One caveat is the example code in index.html at the GitHub link is referencing a local node.js module.
Simply replace:
<script src="./node_modules/ipfs/dist/index.min.js"></script>
With:
<script src="https://cdn.jsdelivr.net/npm/ipfs/dist/index.min.js"></script>
I have made a simple password protected webpage that provides the link to another webpage when we enter the correct password but we can easily have the webadrress of other page by browsers "View Page Source" feature.So how we can overcome this?
The problem is that you are keeping your secret data on the client and client can easily reach it. So, the only posible way for you is to keep them on the server. But, as far as I understand you need help with server part. So here is small instruction with links to the documentation.
You will need:
Some backend that will take data from your users and returns some responce. I would suggest you to have a look into Node.Js as a platform with Express as a server. Benefit from this setup is that Node.Js uses JavaScript so you have not to learn additional language, and Express is a very simple server to use. Of course, if you want to learn some other languages - you can take C# with ASP.NET MVC framework, PHP or any other nice language.
Some page with form for user's credentials that will post data to your backend. Basic form behavior can be found here
And some code on server that will validate credentials from form and return new page with or without your secret.
That's it. May be it sound a bit scary but there are lots of guides and information your can google.
Hope this helps. Happy coding!
Btw, if you are lloking for the some ready code, I have Node.JS client/server example with TypeScript (JavaScript with type validation) here. All you need is git, hope you already have it, and Node.Js
Then just execute this commands on your console (bash, cmd, etc)
git clone https://github.com/Drag13/typescript-browserify-template
This will download code from remote server to your local machine
npm install
Installs project dependencies - like express server
npm run server
Starts the server
cd..
npm run client
Starts the client
Maybe you will find this helpfull.
I am trying to learn NodeJS along with AngularJS. On the frontend, I can simply put debugger statement when I want to put a breakpoint and debug from the browser console. How can I put breakpoints from the server side? In other words, I am looking for a function like pdb in nodejs version.
More specifically, I am trying to learn how to upload files using angularjs on the front and express on the back. When I submit a form with a file attached, a POST request is sent to the server with a set of parameters. Then, the server must submit this form to Amazon S3 with the appropriate credentials. I want to set a breakpoint before submitting the form to Amazon S3 to check the params.
Any help will be appreciated. Thank you!
https://github.com/node-inspector/node-inspector
try this node-inspector, allow you to debug the nodejs just like debugging frontend codes in the chrome devtool
Give it a try for visionmedia debug module.
You may require to configure your node app on your server app.js/main.js/web.js which actually bootstrap your node server app.
var debug = require('debug')('YOUR-APP-NAME');
I appligize if this has already been asked already but I can not find any information about this.
I have an AngularJS application which will be accessed from the hard drive (not from a HTTP server) so the URL in the address will be something like file:///home/user/desktop/app.html)
I am not able to get HTML5-mode URL routing to work. I am using UI-routing module for AngularJS, and whenever I go to file://..../app.html/somepage), the routing does not work. If I set HTML5 mode to false in $locationProvider, and then I go to file://.../app.html#/somepage then it does work.
So is it possible to do? Can someone show me a example where file://-hosted app can with with a URL like file:///myapp.html/somepage ??
Thanks
No. The file:// pseudo-protocol directly queries the local filesystem. For 'fancy' URLs like /myapp.html/somepage to work you need to have a mechanism in between, like Apache's mod_rewrite or FallbackResource which handles those fancy URLs. Since those don't work on the file system, you're out of luck.
Install something like XAMPP to test websites locally through a webserver that is capable of these things.
I have created a php site, doing the basic stuff reading from a sqlite database, logging in etc. This is currently running on xampp on port 80 and all is fine.
I have created another page which is ran on node.js it uses socket.io and express.io.
Currently running on port 8080.
I want to click on a link on the php site that directs me to the node.js page which are both on different ports.
I hope this is understandable, I have done alot of searching on the matter and cannot find a viable solution.
Maybe
Link
If i am wrong please specify your Problem
Change the link to include the port of the node server, like so:
Node Page
If you want to go back from Node to PHP:
PHP Page