Vite Proxy
Since you will be asked to send some requests to servers, you will face CORS
(Cross-Origin Resource Sharing).
To bypass them, we created a vite proxy that will redirect the request to the server.
You can find the proxy in the vite.config.js
file. As this file will be used
and overwritten by the testsuite, do not implement any logic in this file.
If you want to connect to the shared server instead of the local one, you will
have to change the VITE_API_URL
field in the .env
file.
Make sure that you are not using any hardcoded URL in your code. Instead, all
requests should go through the proxy.
In other word, all requests should be made to the client domain
(${import.meta.env.VITE_URL}
) with the correct path (cf. schema),
and never to the server itself (for example, localhost:3333).
The only exception to this rule is the URL for the login page. Since it is not a
request, it will not go through the proxy. You can find the URL in the .env file
and can it be accessed with the import.meta.env.VITE_AUTH_URL
variable.
To use the proxy, all requests must go through the client domain
${import.meta.env.VITE_URL}
) with the endpoint prefixed with the relevant
path:
- /api for the API (ex:
${import.meta.env.VITE_URL}/api/status
) - /socket.io for the streams (ex:
${import.meta.env.VITE_URL}
, socket.io automatically adds the /socket.io path to the URL) - /auth-api for the authentication provider API (ex:
${import.meta.env.VITE_URL}/auth-api/token
)
Refer to the swagger for the API specifications. Adding the content type in some requests’ headers may be necessary.