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

Make API Host configurable to support other regions #49

Closed
wants to merge 1 commit into from

Conversation

gdiphil
Copy link

@gdiphil gdiphil commented Sep 11, 2024

The API Host is currently hard coded. This causes access denied errors if your Storyblok space is located in a region outside of the EU. This pull request is a simple change to allow apiHost to be passed into the client constructor, like this:

final storyblokClient = StoryblokClient(
  accessToken: '<public_access_token>',
  apiHost: 'api-us.storyblok.com',
  storyContentBuilder: (json) => Blok.fromJson(json),
);

More information on Storyblok region API endpoints here:
https://www.storyblok.com/faq/define-specific-region-storyblok-api

Thanks!

Copy link
Collaborator

@PhiFry PhiFry left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! This part was overlooked.

However, now that I did look into it I noticed the base url for china doesnt contain /v2/cdn paths as the other regions do, thus that part must come from this new apiHost parameter.

So, for this PR to fix the issue completelly v2/cdn/ needs to be removed from _pathStories _pathDatasources etc.

Then one could create an enum StoryblokRegion with all supported regions as cases and inside the client constructor do a switch over a new region parameter and set the correct base url.

@tojaskivi
Copy link
Contributor

tojaskivi commented Sep 26, 2024

Hi! This will be fixed in #52.

@tojaskivi tojaskivi closed this Sep 26, 2024
@PhiFry
Copy link
Collaborator

PhiFry commented Oct 7, 2024

@gdiphil This has been fixed now with version 1.3.0, please try it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants