1

I'm following this guide from Apple to create a jwt token to use with their Apple Maps JS Kit: https://developer.apple.com/documentation/mapkitjs/creating_and_using_tokens_with_mapkit_js

It works, but how can I set multiple origins? I wan't it to allow localhost, production-url and production-backend-url. But it looks like it only accepts a string.

Currently I'm doing:

origin:
  process.env.NODE_ENV === "development"
    ? "http://localhost:3000"
    : "https://production-url"

But how can it also allow the third domain?

eivindml
  • 2,197
  • 7
  • 36
  • 68
  • Consider not using a ternary? Try using a function with a swtich statement, or a bunch of if statements which return a value? – evolutionxbox May 13 '21 at 10:49
  • That's not what I'm asking about. I wan't to specify multiple origins. E.g. using an array or some other method. – eivindml May 13 '21 at 10:54
  • Well, a ternary is what is limiting you to only two URLs? You could use an object `const domains = { development: urlA }; domains[process.env.NODE_ENV]`? --- It's good to show what you have already tried rather than asking for ideas on how to implement something. – evolutionxbox May 13 '21 at 10:57
  • Probably not that great question, I can see that it's difficult to figure out what I'm actually asking for. I figured it out, see answer below. :) – eivindml May 13 '21 at 20:01

1 Answers1

2

The syntax for defining multiple origins is like this:

origin: "http://localhost:3000,https://first.domain,https://second.domain"

Figured this out by trial and error. Not documented anywhere I could find.

eivindml
  • 2,197
  • 7
  • 36
  • 68