quran / quran.com-frontend

quran.com frontend
https://quran.com
MIT License
991 stars 360 forks source link

Fix API URL #1079

Closed UmanShahzad closed 5 years ago

UmanShahzad commented 5 years ago

Trying to test the app locally, ran immediately into a couple errors.

  1. staging.quran.com seems to not support HTTPS anymore? Switched to HTTP. Presumably there's no private details here so it's not the worst thing, but having HTTPS again would be nice.
  2. The URL formatting in the API client was adding an extra api/ to the path, so we'd get a URL like api/api/v3/etc. All callers already include api/ in their HTTP request path:
$ git grep 'api/'
config/values.js:      srcEntryFile: './api/index.js',
package-lock.json:      "resolved": "https://registry.npmjs.org/caniuse-api/-/caniuse-api-1.6.1.tgz",
package-lock.json:      "resolved": "https://registry.npmjs.org/istanbul-api/-/istanbul-api-1.3.1.tgz",
src/redux/actions/_tests_/chapterInfos.test.ts:        `/api/v3/chapters/${chapterId}/info`,
src/redux/actions/_tests_/chapters.test.ts:        `/api/v3/chapters/${chapterId}`
src/redux/actions/_tests_/chapters.test.ts:      expect(apiClient.get).toHaveBeenCalledWith('/api/v3/chapters');
src/redux/actions/_tests_/footNotes.test.ts:        `/api/v3/foot_notes/${footNoteId}`
src/redux/actions/_tests_/juzs.test.ts:      expect(apiClient.get).toHaveBeenCalledWith(`/api/v3/juzs`);
src/redux/actions/_tests_/options.test.ts:        `/api/v3/options/translations`
src/redux/actions/_tests_/options.test.ts:      expect(apiClient.get).toHaveBeenCalledWith(`/api/v3/options/recitations`);
src/redux/actions/_tests_/options.test.ts:      expect(apiClient.get).toHaveBeenCalledWith(`/api/v3/options/tafsirs`);
src/redux/actions/_tests_/search.test.ts:      expect(apiClient.get).toHaveBeenCalledWith(`/api/v3/search`, {
src/redux/actions/_tests_/suggest.test.ts:      expect(apiClient.get).toHaveBeenCalledWith(`/api/v3/suggest`, {
src/redux/actions/_tests_/tafsirs.test.ts:        `/api/v3/chapters/${chapterId}/verses/${verseId}/tafsirs`,
src/redux/actions/_tests_/verses.test.ts:        `/api/v3/chapters/${chapterId}/verses`,
src/redux/actions/_tests_/verses.test.ts:        `/api/v3/chapters/${chapterId}/verses`,
src/redux/actions/audioplayer.ts:    `/api/v3/chapters/${chapterId}/verses/${verseId}/audio_files`,
src/redux/actions/chapterInfos.ts:  promise: apiClient.get(`/api/v3/chapters/${chapterId}/info`, {
src/redux/actions/chapters.ts:    promise: apiClient.get('/api/v3/chapters'),
src/redux/actions/chapters.ts:    promise: apiClient.get(`/api/v3/chapters/${id}`),
src/redux/actions/footNotes.ts:  promise: apiClient.get(`/api/v3/foot_notes/${footNoteId}`),
src/redux/actions/juzs.ts:    promise: apiClient.get('/api/v3/juzs'),
src/redux/actions/options.ts:  promise: apiClient.get('/api/v3/options/translations'),
src/redux/actions/options.ts:  promise: apiClient.get('/api/v3/options/recitations'),
src/redux/actions/options.ts:  promise: apiClient.get('/api/v3/options/tafsirs'),
src/redux/actions/search.ts:    promise: apiClient.get('/api/v3/search', {
src/redux/actions/suggest.ts:    promise: apiClient.get('/api/v3/suggest', {
src/redux/actions/tafsirs.ts:    `/api/v3/chapters/${chapterId}/verses/${verseId}/tafsirs`,
src/redux/actions/verses.ts:    promise: apiClient.get(`/api/v3/chapters/${chapterId}/verses`, {
ahmedre commented 5 years ago

Deployed to: http://staging.quran.com:32835

naveed-ahmad commented 5 years ago
http://staging.quran.com:3000/api/v3/chapters
https://staging.quran.com/api/api/v3/chapters

Both are valid URIs. The first api in pathname is mapping to api server in the nginx. Second api is used for actual routing to api module in rails app. I know bit confusing but both http and https are supported.