Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

can really cors be set up globally ? it seems not #393

Open
arnaudambro opened this issue Sep 23, 2024 · 0 comments
Open

can really cors be set up globally ? it seems not #393

arnaudambro opened this issue Sep 23, 2024 · 0 comments

Comments

@arnaudambro
Copy link
Contributor

arnaudambro commented Sep 23, 2024

Describe the bug

On your docs here: https://remix.run/resources/remix-utils

you write:

If you want to setup it globally once, you can do it like this in `entry.server`

I did, quite properly I think here
but it wasn't working, and I lost quite a few hairs on it

until I went to Remix's entry.server doc here: https://remix.run/docs/en/main/file-conventions/entry.server#thrown-responses

where it's written

### Thrown Responses

Note that this does not handle thrown Response instances from your loader/action functions. The intention of this handler is to find bugs in your code which result in unexpected thrown errors. If you are detecting a scenario and throwing a 401/404/etc. Response in your loader/action then it's an expected flow that is handled by your code. If you also wish to log, or send those to an external service, that should be done at the time you throw the response.

so if I understand well, it means that we actually can't setup cors globally, can we ?

Your Example Website or App

https://github.com/betagouv/zacharie/pull/10/files/b293645c87bb84e8efd7da6363dc14a67242303e#diff-dcc994af97e802c6310510c47d7f6b6253b153032fbe29a65b133c88238a77c6

Steps to Reproduce the Bug or Issue

I'm trying to build a pwa but I struggle with ssr/clientActions/actions etc.
so my codebase is a bit ugly you might think, but anyway here I am
you must run yarn dev-spa and yarn prisma-setup && yarn dev-serve and have a local postgres running

Expected behavior

no logs from entry.server when called from _accueil.connexion or tableau-de-bord._index
so the cors required for tableau-de-bord are not setup
meaning that I should setup for each route where I return a json

Screenshots or Videos

No response

Platform

  • OS: [e.g. macOS, Windows, Linux]
  • Browser: [e.g. Chrome, Safari, Firefox]
  • Version: [e.g. 91.1]

Additional context

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant