Skip to content

About

LibGuides Proxy Service for to fetch content for website status page

Resources

Stars

0 stars

Watchers

3 watching

Forks

Latest commit

 

History

38 Commits

Folders and files

Repository files navigation

Library Guides Proxy

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.

Contents


Overview

This project provides four Netlify proxy endpoints:

  1. Global Data Proxy – Returns global library alert banners.
  2. Library Status Updates Proxy – Returns structured library status updates.
  3. FTVA Global Proxy – Returns global alerts for the Film & Television Archive (FTVA).
  4. 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.


Proxy Endpoints

Global Data Proxy

Endpoint

/api/libguides/global/proxy

Purpose

Retrieves library-wide alert banner content, including:

  • Full-width banner alerts
  • Dismissible alert boxes

Response

{
  "bannerAlert": {
    "text": "<p>...</p>"
  },
  "infoAlert": {
    "title": "Alert Title",
    "text": "<p>...</p>"
  }
}

Library Status Updates Proxy

Endpoint

/api/libguides/library/status/updates/proxy

Purpose

Retrieves structured library status updates from the Library Alerts & Status Updates LibGuide.

Each section is extracted from the LibGuide and returned as structured JSON.

Response

Each section contains:

  • sectionTitle
  • richText

Along with any additional structured content such as cards and call-to-actions.


FTVA Global Proxy

Endpoint

/api/libguides/ftva/global/proxy

Purpose

Retrieves Film & Television Archive (FTVA) global alert content from LibGuides.

The proxy returns:

  • Global banner alert
  • Dismissible information alert

Response

{
  "bannerAlert": {
    "text": "<p>...</p>"
  },
  "infoAlert": {
    "title": "Summer Intermission",
    "text": "<p>Screenings will be on pause...</p>"
  }
}

LibGuides Search Proxy

Endpoint

/api/libguides/search/proxy

Function

netlify/functions/searchProxy.js

Purpose

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

Supported functionality

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.

Request example

/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.

Response

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.

CORS and request validation

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.


Setup Instructions

Prerequisites

Install project dependencies:

pnpm install

Install the Netlify CLI:

npm install -g netlify-cli

Local Development

Run the local Netlify development server:

netlify dev

Netlify 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

Testing the Search Proxy

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

Deployment

This project is deployed on Netlify.

Netlify Configuration

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 = 200

Preview Deployments

This 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.


Configuration

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

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"
        }
      ]
    }
  ]
}

Dependencies

  • 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.


Gotchas

If content editors accidentally delete the box on the LibGuides page

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

Steps to fix

1. Update the LibGuide URL

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

2. Update the HTML selector

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

If the FTVA LibGuide content is recreated

The same process applies to the FTVA proxy.

If an FTVA content box is deleted and recreated:

  1. Update the Box ID, Map ID, and Config ID in:
netlify/functions/ftvaGlobalProxy.js
  1. 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.


If LibGuides Search stops working

Check the following:

  1. Verify that the upstream endpoint https://guides.library.ucla.edu/srch_process_cs.php is accessible.
  2. Confirm that Springshare has not changed its search actions, source IDs, or request parameters.
  3. Check Netlify Function logs for upstream errors or timeouts.
  4. Verify that the frontend origin is included in ALLOWED_ORIGINS in searchProxy.js.
  5. 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.

About

LibGuides Proxy Service for to fetch content for website status page

Resources

Stars

0 stars

Watchers

3 watching

Forks

Releases

Packages

Used by

Contributors

Languages