A simple search application built completely with AngularJS on NoSQL MarkLogic database
- Install free developer version of MarkLogic
- Go to AppBuilder at
http://localhost:8000/appservices
- Give name for the app, say Oscars, give name for database, say Oscar-DB.
- Follow through the setup wizard with default settings and deploy the app on default port (5275) or give different port, say 8003
- This essentially deploys the application on REST server attached to Oscars-DB containing 9 documents
- Git clone this repo
- cd angularjs-oscars
- npm install
- npm start
Option 1: Add this piece of code in search-list-query.xqy
available at /Users/<username>/Library/MarkLogic/Modules/MarkLogic/rest-api/endpoints dir for GET and POST. This is important for the server to handle requests from the app
replace
return if (exists($response)) then $response
with
return
if (exists($response)) then
(eput:add-response-header("Access-Control-Allow-Origin", xdmp:get-request-header('Origin')),
eput:add-response-header("Access-Control-Allow-Credentials","true"),
$response)
Option 2: Set up a proxy server using expressjs
or http-proxy
or any other proxy server that essentially helps you enable CORS