Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MIR-12: CORS access and more flexible config #10

Merged
merged 2 commits into from
Jan 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,15 @@ There are some environment variables to help integrate with IIIF Image APIs, in

Presently, we indicate `level2` compliance for each IIIF Image API endpoint.

As a point of convenience, it is possible to specify the `IIIF_IMAGE_V*_SLUG`
values using `base:`, as used by
[Drupal's `Url::fromUri()`](https://api.drupal.org/api/drupal/core%21lib%21Drupal%21Core%21Url.php/function/Url%3A%3AfromUri/10).
For example, if you are using a proxy to make a `/iiif/2` path for a IIIF-I v2
endpoint, such that your slug would be
`https://{your hostname}/iiif/2/{identifier}`, then you can instead use
`base:/iiif/2/{identifier}` to configure the reference more explicitly relative
to the hostname used to access the site.

## Troubleshooting/Issues

Having problems or solved one? contact
Expand Down
6 changes: 5 additions & 1 deletion src/Controller/V3/ManifestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,11 @@ public function build(string $parameter_name, RouteMatchInterface $route_match)
return (new JsonResponse(
$this->serializer->serialize($_entity, 'iiif-p-v3'),
200,
[],
[
'Access-Control-Allow-Credentials' => 'true',
'Access-Control-Allow-Origin' => '*',
'Access-Control-Allow-Methods' => 'GET',
],
TRUE
));
}
Expand Down
5 changes: 3 additions & 2 deletions src/EventSubscriber/V3/BaseImageBodyEventSubscriber.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Drupal\iiif_presentation_api\EventSubscriber\V3;

use Drupal\Component\Plugin\PluginManagerInterface;
use Drupal\Core\Url;
use Drupal\file\FileInterface;
use Drupal\iiif_presentation_api\Event\V3\ImageBodyEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
Expand Down Expand Up @@ -75,13 +76,13 @@ protected function getBody(?string $slug, FileInterface $file, array $extra = []
'{identifier}' => rawurlencode($id_plugin->getIdentifier($file)),
]);
return [
'id' => "{$base_id}/full/{$size}/0/default.jpg",
'id' => Url::fromUri("{$base_id}/full/{$size}/0/default.jpg", ['absolute' => TRUE])->toString(),
'type' => 'Image',
'format' => 'image/jpeg',
'service' => [
[
// @todo Add in auth in some manner.
'id' => $base_id,
'id' => Url::fromUri($base_id, ['absolute' => TRUE])->toString(),
] + $extra,
],
];
Expand Down
Loading