This repository hosts Netlify serverless functions that retrieve content and data from UCLA Library LibGuides for frontend applications.
Some functions extract HTML content and return structured JSON. Others, such as the Search Proxy, forward live Springshare API responses without modifying their structure.
- Overview
- Proxy Endpoints
- Setup Instructions
- Deployment
- Configuration
- Example Response
- Dependencies
- Gotchas
This project provides four Netlify proxy endpoints:
- Global Data Proxy – Returns global library alert banners.
- Library Status Updates Proxy – Returns structured library status updates.
- FTVA Global Proxy – Returns global alerts for the Film & Television Archive (FTVA).
- LibGuides Search Proxy – Forwards live Springshare Search requests to support dynamic searching from frontend applications hosted on other domains.
The Search Proxy is primarily intended for the LibGuides Frontend GitHub Pages previews.
Endpoint
/api/libguides/global/proxy
Retrieves library-wide alert banner content, including:
- Full-width banner alerts
- Dismissible alert boxes
{
"bannerAlert": {
"text": "<p>...</p>"
},
"infoAlert": {
"title": "Alert Title",
"text": "<p>...</p>"
}
}Endpoint
/api/libguides/library/status/updates/proxy
Retrieves structured library status updates from the Library Alerts & Status Updates LibGuide.
Each section is extracted from the LibGuide and returned as structured JSON.
Each section contains:
sectionTitlerichText
Along with any additional structured content such as cards and call-to-actions.
Endpoint
/api/libguides/ftva/global/proxy
Retrieves Film & Television Archive (FTVA) global alert content from LibGuides.
The proxy returns:
- Global banner alert
- Dismissible information alert
{
"bannerAlert": {
"text": "<p>...</p>"
},
"infoAlert": {
"title": "Summer Intermission",
"text": "<p>Screenings will be on pause...</p>"
}
}Endpoint
/api/libguides/search/proxy
Function
netlify/functions/searchProxy.js
Enables live Springshare Search functionality from frontend applications hosted outside the LibGuides domain, including GitHub Pages pull request previews.
Because Springshare's Search endpoint does not allow direct cross-origin browser requests from the local development origin tested, the Netlify Function acts as a server-side proxy.
The function forwards requests to:
https://guides.library.ucla.edu/srch_process_cs.php
The proxy is designed to support:
- Live search queries
- Research Guides search results
- A–Z Database List search results
- Sorting
- Filtering
- Pagination
These capabilities depend on Springshare's supported request parameters. Each interaction should be verified during frontend integration.
/api/libguides/search/proxy?q=news&action=580&search_source_id=2012&layout=bento&start=0&group_id=0
The function supports the following search actions:
| Action | Search source |
|---|---|
580 |
Research Guides initial search |
581 |
Research Guides sorting and filtering |
582 |
A–Z Database List initial search |
583 |
A–Z Database List sorting and filtering |
The configured source IDs are 2012 for Research Guides and 2013 for A–Z Database List.
Unlike the other proxies, the Search Proxy returns Springshare's JSON response without transforming the result structure.
Example (abbreviated):
{
"errCode": 200,
"errText": "OK",
"data": {
"results": "<div class=\"s-srch-results\">...</div>",
"facets": "<fieldset class=\"s-lg-facet-div\">...</fieldset>",
"description": "",
"title": "Search for news",
"q": "news",
"fulllink": "https://guides.library.ucla.edu/srch.php?default_lg=1&q=news"
},
"version": "x.x"
}The results and facets fields contain HTML generated by Springshare.
The Search Proxy:
- Allows requests from configured frontend origins, including UCLA Library GitHub Pages previews and local development.
- Supports GET and OPTIONS requests.
- Validates supported search actions, source IDs, and request parameters.
- Uses a fixed Springshare upstream endpoint.
- Applies request timeouts and response-size checks.
- Returns JSON errors when requests fail.
Allowed origins and search parameters are configured in searchProxy.js.
CORS is not authentication or rate limiting. Public deployment should use appropriate Netlify-side abuse protection.
Install project dependencies:
pnpm installInstall the Netlify CLI:
npm install -g netlify-cliRun the local Netlify development server:
netlify devNetlify Functions will be available locally.
Examples:
Global Data Proxy
http://localhost:8888/api/libguides/global/proxy
Library Status Updates Proxy
http://localhost:8888/api/libguides/library/status/updates/proxy
FTVA Global Proxy
http://localhost:8888/api/libguides/ftva/global/proxy
LibGuides Search Proxy
http://localhost:8888/api/libguides/search/proxy?q=news&action=580&search_source_id=2012&layout=bento&start=0&group_id=0
Run:
curl -i "http://localhost:8888/api/libguides/search/proxy?q=news&action=580&search_source_id=2012&layout=bento&start=0&group_id=0"A successful request should return HTTP 200 with Springshare JSON containing errCode: 200.
To test CORS headers for GitHub Pages:
curl -i \
-H "Origin: https://uclalibrary.github.io" \
"http://localhost:8888/api/libguides/search/proxy?q=news&action=580&search_source_id=2012&layout=bento&start=0&group_id=0"Check for:
Access-Control-Allow-Origin: https://uclalibrary.github.io
This project is deployed on Netlify.
The project uses the following configuration in netlify.toml:
[build]
functions = "netlify/functions"
[[redirects]]
from = "/api/libguides/global/proxy"
to = "/.netlify/functions/globalDataProxy"
status = 200
[[redirects]]
from = "/api/libguides/library/status/updates/proxy"
to = "/.netlify/functions/libraryStatusUpdatesProxy"
status = 200
[[redirects]]
from = "/api/libguides/ftva/global/proxy"
to = "/.netlify/functions/ftvaGlobalProxy"
status = 200
[[redirects]]
from = "/api/libguides/search/proxy"
to = "/.netlify/functions/searchProxy"
status = 200This repository is connected to GitHub and Netlify.
Whenever a pull request is opened or updated:
- GitHub Actions automatically builds the branch.
- Netlify creates a Preview Deployment.
- A preview URL is posted back to the pull request, allowing reviewers to test changes before merging.
Once the pull request is merged into the main branch, Netlify automatically deploys the latest production version.
All LibGuide URLs, Box IDs, Map IDs, Config IDs, and HTML selectors are configured within the corresponding Netlify Function.
If LibGuides content changes, these values may need to be updated.
For the Search Proxy, configuration includes:
- Springshare Search endpoint
- Allowed frontend origins
- Supported search actions and source IDs
- Allowed query parameters
- Request timeout and response-size limits
Search configuration is maintained in:
netlify/functions/searchProxy.js
Example response from the Library Status Updates Proxy:
{
"summary": "<p>Last updated Tuesday, July 15, 2025.</p>",
"blocks": [
{
"id": "4243666",
"typeHandle": "richText",
"sectionTitle": "Access to Libraries and Services",
"richText": "<ul>...</ul>"
},
{
"id": "4243668",
"typeHandle": "richText",
"sectionTitle": "Planned Library Construction",
"richText": "<p>No planned construction at this time.</p>"
},
{
"id": "4243669",
"typeHandle": "simpleCards",
"sectionTitle": "Additional Campus Resources",
"cards": [
{
"title": "Bruins Safe Online",
"externalLink": "https://bso.ucla.edu"
}
]
}
]
}- Node.js
- Netlify Functions
- Netlify CLI
- jsdom (used by HTML-parsing functions)
The Search Proxy uses native JavaScript APIs and does not require jsdom or additional dependencies.
Library Alerts & Status Updates
Admin page:
https://ucla.libapps.com/libguides/admin_c.php?g=1427138
Public page:
https://guides.library.ucla.edu/c.php?g=1427138&p=10587194#s-lg-box-wrapper-40758929
If the content box is deleted and recreated, LibGuides generates new:
- Box ID
- Map ID
- Config ID
Update the corresponding URL in the Netlify Function.
Example:
https://github.com/UCLALibrary/libguides-proxy/blob/main/netlify/functions/libraryStatusUpdatesProxy.js#L63
After recreating the box, LibGuides also generates a new HTML element ID.
Update the selector used to extract the content.
Example:
https://github.com/UCLALibrary/libguides-proxy/blob/main/netlify/functions/libraryStatusUpdatesProxy.js#L122
The same process applies to the FTVA proxy.
If an FTVA content box is deleted and recreated:
- Update the Box ID, Map ID, and Config ID in:
netlify/functions/ftvaGlobalProxy.js
- Update any HTML element IDs used by the parser (for example,
s-lg-content-xxxxxxxx) to match the newly generated LibGuides markup.
Failure to update these IDs will result in empty bannerAlert or infoAlert responses.
Check the following:
- Verify that the upstream endpoint
https://guides.library.ucla.edu/srch_process_cs.phpis accessible. - Confirm that Springshare has not changed its search actions, source IDs, or request parameters.
- Check Netlify Function logs for upstream errors or timeouts.
- Verify that the frontend origin is included in
ALLOWED_ORIGINSinsearchProxy.js. - Confirm that the frontend Search adapter is using the correct Netlify endpoint.
The Search Proxy does not cache search results. Requests are forwarded to Springshare when received.