Skip to content

Commit

Permalink
fix(SSR): manage token
Browse files Browse the repository at this point in the history
  • Loading branch information
emile-bex committed Jun 3, 2021
1 parent a7d6c53 commit ef2631b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/adapters/gateways/HTTPFeedGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export class HTTPFeedGateway implements IFeedGateway {
}
}

return api.request({
return api.ssr().request({
name: '/feeds GET',
params: {
types: data.filters.types,
Expand Down Expand Up @@ -154,7 +154,7 @@ export class HTTPFeedGateway implements IFeedGateway {
}

retrieveFeedItem(data: { entourageUuid: string; }) {
return api.request({
return api.ssr().request({
name: '/entourages/:entourageId GET',
pathParams: {
entourageUuid: data.entourageUuid,
Expand Down
4 changes: 2 additions & 2 deletions src/adapters/gateways/HTTPPOIsGateway.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export class HTTPPOIsGateway implements IPOIsGateway {
}
}

return api.request({
return api.ssr().request({
name: '/pois GET',
params: {
v: 2,
Expand Down Expand Up @@ -61,7 +61,7 @@ export class HTTPPOIsGateway implements IPOIsGateway {
}

retrievePOI: IPOIsGateway['retrievePOI'] = (data) => {
return api.request({
return api.ssr().request({
name: '/pois/:poiUuid GET',
params: {
v: 2,
Expand Down
4 changes: 2 additions & 2 deletions src/core/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,14 @@ addAxiosInterceptors(axiosInstance)

type APIInstanceWithSSR = {
request: typeof request;
ssr: (ctx: NextPageContext) => {
ssr: (ctx?: NextPageContext) => {
request: typeof request;
};
}

export const api: APIInstanceWithSSR = {
request,
ssr: (ctx) => ({
ssr: (ctx?) => ({
request: async (config) => {
const token = getTokenFromCookies(ctx) || await createAnonymousUser(ctx)

Expand Down

0 comments on commit ef2631b

Please sign in to comment.