I have a .Net Web API service running with windows authentication enabled. I've a separate UI application for which webpack is setup. I'm trying to setup webpack proxy to access my service. Here is my current configuration
"proxy": {
"/api/*": {
"target": "http://localhost:50643",
}
}
I'm getting a 401 (Unauthorized) error now. How do I setup webpack proxy to enable authentication.
You can provide auth prop:
"proxy": {
"/api/*": {
"target": "http://localhost:50643",
"auth": "username:password"
}
}
Related
I am trying to understand how certificates work with asp.net 5.0. I have created a self signed certificate using PKI Client and installed it to the certificate store trusted root.
I have updated my Kestrel config as below
"Kestrel": {
"EndPoints": {
"Http": {
"Url": "http://localhost:5000"
},
"HttpsInlineCertStore": {
"Url": "https://*:5001",
"Certificate": {
"Subject": "pal.com",
"Store": "My",
"Location": "LocalMachine",
"AllowInvalid": "false" // Set to true to allow invalid certificates (e.g. self-signed)
}
}
}
}
When I run my server and browse to path https://pal.com:5001/ it complains about the certificate. It looks like the browser is using the asp.net core development certificate
I am new to asp.net and ssl. Am I missing anything here?
ok, I got this working. That was me doing things incorrectly, I added Kestrel config in launchSettings file rather than appsettings. It worked after moving the config to appsettings.json file
i had created a Vuejs project with PWA support but when i am building its production build it always using cached version of api requests i want to prevent it from using cache for api requests or change its policy from being to cacheFirst to NetworkFirst for api i found a i had changed vue.config.js to prevent cacheing but its not working
pwa: {
workboxOptions: {
exclude: [/.*\/api\//,],
},
},
any help on how i can either prevent cache on api routes or set networkFirst policy
exclude option only works for excluding precaching assets, which is what vue generates at build time, not api requests at run time.
It seems the Cache-Control problem of the api server, but if you do not have access to that server, you can config NetworkFirst policy runtimeCaching:
module.exports = {
pwa: {
workboxOptions: {
runtimeCaching: [{
urlPattern: new RegExp('^https://api.example.com/path'),
handler: 'NetworkFirst',
}]
}
}
};
maybe somebody use cypress for testing e2e flows together with backend API calls without some mocks.
I have a trouble right now, I want to use my local API from simple Laravel server like
http://127.0.0.1:8000, but all my XHR request aborted when I run tests. After some investigations I understood that if I change request baseUrl to https://example.com then requests works fine.
Example of XHR aborting
I already set chromeWebSecurity to false.
Cypress version: 4.0.2
cypress.json
{
"viewportWidth": 1920,
"viewportHeight": 1000,
"baseUrl": "http://localhost:4200",
"watchForFileChanges": false,
"integrationFolder": "cypress/build/cypress/integration",
"chromeWebSecurity": false,
"blacklistHosts": [],
"env": {
"host": "http://localhost:4200",
"baseUrl": "http://127.0.0.1:8000/api"
}
}
I have configured devserver in vue-config.js before like this:
devServer: {
proxy: {
"/api/*": {
target: "http://localhost:3001",
secure: false
}
}
}
In nuxt-SPA this dont work. My front is still sending API-calls to same origin localhost:3000. How to configure API-calls to different port?
Duplicate of
How to use webpack dev proxy with Nuxt
https://github.com/nuxt/nuxt.js/issues/762
Due to its unversal app nature Nuxts doe not have webpack proxy.
Simpliest one to implement is here - https://github.com/nuxt-community/proxy-module
I want to make requests to api on another website.
I know that in Angular you can have a file proxy.conf.json with something like this
{
"/api": {
"target": "website.com",
"secure": false,
"changeOrigin": true,
"logLevel": "debug"
}
}
Is there a way to do this in vue if I don't use vue-cli?
Ended up using express server with webpack dev middleware and express-http-proxy