since the user is passed in params, and in POST they're sent as a JSON body, we need to: 1) parse the params from the JSON manually, Sinatra doesn't do that 2) add an OPTIONS route for the CORS preflight
···26262727 def get_user_did
2828 if settings.development?
2929- if did = params[:user]
2929+ did = if request.post?
3030+ json = JSON.parse(request.body.read)
3131+ request.body.rewind
3232+ json['user']
3333+ else
3434+ params[:user]
3535+ end
3636+3737+ if did
3038 return did
3139 else
3240 halt json_error('AuthMissing', 'Missing "user" parameter', status: 401)
···113121 end
114122115123 json_response(terms: query.terms, posts: post_uris, cursor: items.last&.cursor)
124124+ end
125125+126126+ if settings.development?
127127+ options '/xrpc/blue.feeds.lycan.startImport' do
128128+ headers['Access-Control-Allow-Origin'] = '*'
129129+ headers['Access-Control-Allow-Headers'] = 'content-type'
130130+ end
116131 end
117132118133 post '/xrpc/blue.feeds.lycan.startImport' do