I am trying to learn a JS framework to use with Drupal via rest, but I am getting caught up in Drupal / server configuration. Spending way too much time trying to figure this out, maybe someone with some experience here could help me so I can get back to learning the "stuff"?
Essentially, I have a VPS, nginx with two vhosts, one on port 9080, the other 8080.
I have drupal 8, restful, hal, and serialization enabled and a basic restful export view set up. When I go to the view URL in the browser, I see JSON. Perfect. This is on port :8080
On port :9080, I have my little Vue.js app that I am building to learn. Vue.js is pretty nice actually. So, in my Vue.js app, I am trying to pull that view data from :8080.
So, first off, I run into the whole CORS thing. I spent several hours trying to find good information on how to set this up in nginx, eventually went with this guy's script: https://gist.github.com/agouriou/735daacf7530675552ff248f319a07d9
But now I get 404 when I try to hit that URL from the app. I have tested using curl, and this little Advanced REST client app for chrome, and half a dozen online CORS checkers. I am getting different results from different places, but the one I care about, the app, is not working.
Using the Advanced REST client, I get 200 OK, and I see the stream of data.
In curl, with the command:
$ curl -H "Origin: http://xxx.xxx.xxx.xxx:9080
" --verbose http://xxx.xxx.xxx.xxx:8080/api/getImages
* Trying xxx.xxx.xxx.xxx...
* Connected to xxx.xxx.xxx.xxx (xxx.xxx.xxx.xxx) port 8080 (#0)
> GET /api/getImages HTTP/1.1
> Host: xxx.xxx.xxx.xxx:8080
> User-Agent: curl/7.47.0
> Accept: /
> Origin: http://xxx.xxx.xxx.xxx:9080
< HTTP/1.1 404 Not Found
< Server: nginx/1.10.0 (Ubuntu)
< Date: Thu, 22 Dec 2016 08:33:50 GMT
< Content-Type: text/html
< Content-Length: 178
< Connection: keep-alive
< Access-Control-Allow-Origin: http://xxx.xxx.xxx.xxx:9080
< Access-Control-Allow-Credentials: true
< Access-Control-Allow-Methods: GET, POST, PUT, DELETE, OPTIONS
< Access-Control-Allow-Headers: Accept,Authorization,Cache-Control,Content-Type,DNT,If-Modified-Since,Keep-Alive,Origin,User-Agent,X-Mx-ReqToken,X-Requested-With
< Access-Control-Expose-Headers: Authorization
I also installed the CORS drupal 8 module, I don't have any idea if that is set up right.
I feel like there is this chunk of knowledge I am missing, that I don't really care about, can't really find a way to get through to get back to the thing I care about.
If you have any experience and know of a really good tutorial on how to get this working, please share. I probably need to take this to stackexchange, but I always get yelled at over there.