Skip to content

Conversation

Madeorsk
Copy link
Contributor

@Madeorsk Madeorsk commented Sep 5, 2025

Problem

Demo / CRM examples are not working in production when using Safari.

Solution

Use https://crm.api.marmelab.com / https://demo.api.marmelab.com instead of http://localhost:4000 for the fake server handled by MSW.

How To Test

Visit https://marmelab.com/react-admin-crm and https://marmelab.com/react-admin-demo with Safari.

Additional Checks

  • The PR targets master for a bugfix or a documentation fix, or next for a feature
  • [ ] The PR includes unit tests (if not possible, describe why)
  • [ ] The PR includes one or several stories (if not possible, describe why)
  • The documentation is up to date

@Madeorsk Madeorsk added WIP Work In Progress RFR Ready For Review and removed WIP Work In Progress labels Sep 5, 2025
Copy link
Collaborator

@djhi djhi left a comment

Choose a reason for hiding this comment

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

WDYT?

import { withSupabaseFilterAdapter } from './internal/supabaseAdapter';

const baseDataProvider = simpleRestProvider('http://localhost:4000');
const baseDataProvider = simpleRestProvider('https://localhost:4000');
Copy link
Collaborator

Choose a reason for hiding this comment

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

As this is never accessed anyway, why not even put something that looks like a real api?

Suggested change
const baseDataProvider = simpleRestProvider('https://localhost:4000');
const baseDataProvider = simpleRestProvider('https://crm.api.marmelab.com');

Copy link
Contributor Author

@Madeorsk Madeorsk Sep 5, 2025

Choose a reason for hiding this comment

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

I thought about it but wasn't sure that it was a good idea, but let's try it!

const dataProvider = buildApolloClient({
clientOptions: {
uri: 'http://localhost:4000/graphql',
uri: 'https://localhost:4000/graphql',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Same for those?

Suggested change
uri: 'https://localhost:4000/graphql',
uri: 'https://ecommerce.api.marmelab.com/graphql',

import simpleRestProvider from 'ra-data-simple-rest';

export default simpleRestProvider('http://localhost:4000');
export default simpleRestProvider('https://localhost:4000');
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
export default simpleRestProvider('https://localhost:4000');
export default simpleRestProvider('https://ecommerce.api.marmelab.com/graphql');

const data = generateData();
const adapter = new MswAdapter({
baseUrl: 'http://localhost:4000',
baseUrl: 'https://localhost:4000',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
baseUrl: 'https://localhost:4000',
baseUrl: 'https://ecommerce.api.marmelab.com/graphql',

}
const worker = setupWorker(http.all(/http:\/\/localhost:4000/, fakeServer));
const worker = setupWorker(
http.all(/https:\/\/localhost:4000/, fakeServer)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
http.all(/https:\/\/localhost:4000/, fakeServer)
http.all(/https:\/\/ecommerce\.api\.marmelab\.com:4000/, fakeServer)


const handler = getMswHandler({
baseUrl: 'http://localhost:4000',
baseUrl: 'https://localhost:4000',
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
baseUrl: 'https://localhost:4000',
baseUrl: 'https://crm.api.marmelab.com',

});
export const worker = setupWorker(http.all(/http:\/\/localhost:4000/, handler));
export const worker = setupWorker(
http.all(/https:\/\/localhost:4000/, handler)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
http.all(/https:\/\/localhost:4000/, handler)
http.all(/https:\/\/crm\.api\.marmelab\.com:4000/, handler)

@djhi djhi added this to the 5.11.2 milestone Sep 8, 2025
@djhi djhi merged commit 09f845e into master Sep 8, 2025
15 checks passed
@djhi djhi deleted the fix-demo-msw branch September 8, 2025 08:58
@slax57 slax57 changed the title Fix demos with MSW [Demo] Fix demos with MSW Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
RFR Ready For Review
Development

Successfully merging this pull request may close these issues.

2 participants