Skip to content

Commit

Permalink
fix(requests): use relative request paths (#1175)
Browse files Browse the repository at this point in the history
* use relative authority

* use relative request path
  • Loading branch information
andrewazores authored Dec 11, 2023
1 parent 917f011 commit 991011f
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/app/Shared/Services/Login.service.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export class LoginService {
private readonly authCredentials: AuthCredentials,
private readonly settings: SettingsService,
) {
this.authority = process.env.CRYOSTAT_AUTHORITY || '';
this.authority = process.env.CRYOSTAT_AUTHORITY || '.';
this.token.next(this.getCacheItem(this.TOKEN_KEY));
this.username.next(this.getCacheItem(this.USER_KEY));
this.authMethod.next(this.getCacheItem(this.AUTH_METHOD_KEY) as AuthMethod);
Expand Down
2 changes: 1 addition & 1 deletion src/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<title>Cryostat</title>
<meta id="appName" name="application-name" content="Cryostat">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<base href="/">
<base href="./">
</head>

<body>
Expand Down
2 changes: 1 addition & 1 deletion src/mirage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -399,7 +399,7 @@ export const startMirage = ({ environment = 'development' } = {}) => {
},
]);
this.get('api/v2/probes', () => []);
this.post('/api/beta/matchExpressions', (_, request) => {
this.post('api/beta/matchExpressions', (_, request) => {
const attr = JSON.parse(request.requestBody);
if (!attr.matchExpression || !attr.targets) {
return new Response(400);
Expand Down
10 changes: 5 additions & 5 deletions src/test/Shared/Services/Login.service.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ describe('Login.service', () => {
it('should make expected API calls', async () => {
await firstValueFrom(svc.setLoggedOut());
expect(mockFromFetch).toHaveBeenCalledTimes(3);
expect(mockFromFetch).toHaveBeenNthCalledWith(2, `/api/v2.1/auth`, {
expect(mockFromFetch).toHaveBeenNthCalledWith(2, `./api/v2.1/auth`, {
credentials: 'include',
mode: 'cors',
method: 'POST',
Expand All @@ -126,7 +126,7 @@ describe('Login.service', () => {
Authorization: `Basic dXNlcjpkNzRmZjBlZThkYTNiOTgwNmIxOGM4NzdkYmYyOWJiZGU1MGI1YmQ4ZTRkYWQ3YTNhNzI1MDAwZmViODJlOGYx`,
}),
});
expect(mockFromFetch).toHaveBeenNthCalledWith(3, `/api/v2.1/logout`, {
expect(mockFromFetch).toHaveBeenNthCalledWith(3, `./api/v2.1/logout`, {
credentials: 'include',
mode: 'cors',
method: 'POST',
Expand Down Expand Up @@ -230,7 +230,7 @@ describe('Login.service', () => {
it('should make expected API calls', async () => {
await firstValueFrom(svc.setLoggedOut());
expect(mockFromFetch).toHaveBeenCalledTimes(3);
expect(mockFromFetch).toHaveBeenNthCalledWith(1, `/api/v2.1/auth`, {
expect(mockFromFetch).toHaveBeenNthCalledWith(1, `./api/v2.1/auth`, {
credentials: 'include',
mode: 'cors',
method: 'POST',
Expand All @@ -239,7 +239,7 @@ describe('Login.service', () => {
Authorization: `Bearer c2hhMjU2fmhlbGxvd29ybGQ`,
}),
});
expect(mockFromFetch).toHaveBeenNthCalledWith(2, `/api/v2.1/logout`, {
expect(mockFromFetch).toHaveBeenNthCalledWith(2, `./api/v2.1/logout`, {
credentials: 'include',
mode: 'cors',
method: 'POST',
Expand All @@ -248,7 +248,7 @@ describe('Login.service', () => {
Authorization: `Bearer c2hhMjU2fmhlbGxvd29ybGQ`,
}),
});
expect(mockFromFetch).toHaveBeenNthCalledWith(3, `/api/v2.1/auth`, {
expect(mockFromFetch).toHaveBeenNthCalledWith(3, `./api/v2.1/auth`, {
credentials: 'include',
mode: 'cors',
method: 'POST',
Expand Down
3 changes: 1 addition & 2 deletions webpack.common.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ const HtmlWebpackPlugin = require('html-webpack-plugin');
const TsconfigPathsPlugin = require('tsconfig-paths-webpack-plugin');

const BG_IMAGES_DIRNAME = 'bgimages';
const ASSET_PATH = process.env.ASSET_PATH || '/';

module.exports = (env) => {
return {
Expand Down Expand Up @@ -154,7 +153,7 @@ module.exports = (env) => {
chunkFilename: '[id].[contenthash].bundle.js', // lazy-load modules
hashFunction: "xxhash64",
path: path.resolve(__dirname, 'dist'),
publicPath: ASSET_PATH,
publicPath: 'auto',
clean: true
},
resolve: {
Expand Down

0 comments on commit 991011f

Please sign in to comment.