angular-http-server | Simple http-server for single-page apps | REST library
kandi X-RAY | angular-http-server Summary
kandi X-RAY | angular-http-server Summary
Simple http-server for single-page apps (SPAs)
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
Currently covering the most popular Java, JavaScript and Python libraries. See a Sample of angular-http-server
angular-http-server Key Features
angular-http-server Examples and Code Snippets
Community Discussions
Trending Discussions on angular-http-server
QUESTION
I'm trying to run angular dist in the background and I'm targeting the node_modules folder in the dist correctly and finding the angular-http-server library there. The terminal is not showing any error but it's not starting. I'm using this command:
...ANSWER
Answered 2019-Nov-27 at 11:41You may use it like this:
QUESTION
I've enabled CORS successfully in development. My Golang back end communicates well with my Angular front end on my local machine. However, I can't figure out how to enable CORS in production (Ubuntu on DigitalOcean). I get this on Firefox:
"Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:12345/anteroom. (Reason: CORS request did not succeed)."
I'm running the Golang back end with a systemd unit and serving it at localhost:12345.
I'm running the Angular front end as a build (built with --prod
flag) using PM2 with angular-http-server, and serving it out of port 8080. This port is behind a firewall. I use Nginx to handle HTTPS traffic for this front end. It listens on port 80 and passes (proxy_pass
) requests to it at port 8080. The landing page (which requires only a GET request) loads ok in the browser, so this setup seems feasible.
The versions I'm working with: Ubuntu 16.04, PM2 3.3.1, Angular CLI 7.3.4, angular-http-server 1.8.1.
The problem happens when the front end tries to POST JSON data to the back end (localhost:12345/anteroom, as seen in the message above).
I've read that CORS is a server-side issue. So, I've tried enabling it wherever I've a server, that is, in the back end, Nginx, and angular-http-server.
It's enabled in my Golang code:
...ANSWER
Answered 2019-Mar-07 at 07:27 func anteroom(res http.ResponseWriter, req *http.Request) {
res.Header().Set("Access-Control-Allow-Origin", "*")
res.Header().Set("Access-Control-Allow-Methods", "POST, OPTIONS")
res.Header().Set("Access-Control-Allow-Headers", "Content-Type")
res.Header().Set("Content-Type", "application/json")
...
}
func main() {
...
# Using Gorilla mux router.
router := mux.NewRouter()
router.HandleFunc("/anteroom", anteroom).Methods("POST", "OPTIONS")
}
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
Install angular-http-server
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page